python - 如何将注释箭头添加到图例
问题描述
我有一些机器人的轨迹,以及一些描述机器人参数的箭头。就像这样: Robot Trajectory with annotation arrows (由于我的声誉不足,无法直接添加图片)
问题是:如何将注释箭头与图例中的线条一起显示?
我使用注释箭头来根据这个答案在循环中绘制箭头,为每个点绘制箭头。这是我的注释之一的代码:
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
)添加到我的图例中?
解决方案
推荐阅读
- express-gateway - 在 express-gateway UI 中跳过 oauth 流中的请求范围
- windows - 如何在 Windows 上使用 pg_upgrade 在 PostgreSQL 上从 v10 迁移到 V11?
- react-native - 从后台模式返回时更新数据
- python - 将熊猫数据框转换为日期时间
- eclipse-hono - 没有k8s如何启动hono?
- angular - 在Angular中将数据从服务传递到模态组件
- java - 在 Android 的房间 db 中插入复合键的重复值后,应用程序崩溃
- javascript - 带有嵌套 IF 语句的 FOR LOOP
- dita - 有人能说一下这个 catalog-dita.xml 文件是什么,我如何转换为 xml 并返回?
- vue.js - @nuxtjs/auth 为什么刷新页面总是重定向到登录