【发布时间】:2019-08-01 08:52:07
【问题描述】:
我有一些机器人的轨迹,以及一些描述机器人参数的箭头。就像这样: Robot Trajectory with annotation arrows (因为我没有名气,不能直接加图)
问题是:如何将注释箭头与图例中的线条一起显示?
我使用注释箭头来根据answer 在循环中绘制箭头,为每个点绘制箭头。 这是我的注释之一的代码:
an = ax.annotate('', xy=xy_tuple, xytext=xy_texttuple, label=labelString, arrowprops=dict(color=arrowcolor, arrowstyle=aStyle))
作为参考,我使用绘图功能如下:
# plot Local x-y axis
fig, ax1 = plt.subplots()
ln1 = ax1.plot(x, y, '-o', label='Location of the last 48h')
ax1.set_ylabel('Local North (m)')
ax1.set_xlabel('Local East (m)')
ax1.grid()
fig.gca().set_aspect('equal', adjustable='box')
lns = ln1
labs = [l.get_label() for l in lns]
ax1.legend(lns, labs, loc='best')
那么如何将注释标签(由labelString 提供)添加到我的图例中?
【问题讨论】:
-
参见github.com/matplotlib/matplotlib/issues/8236,其中也有解决方案。
标签: python matplotlib annotate arrows