在 Matplotlib/Python 中将小照片/图像添加到大图中
我有一个在 matplotlib 中生成的大图。我想在该图中的某些 (x,y) 坐标处添加一些图标。我想知道在 matplotlib 中是否有任何方法可以做到这一点
谢谢
I have a large graph that I am generating in matplotlib. I'd like to add a number of icons to this graph at certain (x,y) coordinates. I am wondering if there is any way to do that in matplotlib
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这绝对是可能的。这是一个开始:
图标重叠 http://up.stevetjoa.com/iconoverlap.png
在此示例中,图标的位置未根据绘图的 (x,y) 坐标定义;也许其他人可以帮忙。尽管如此,我希望这个例子能有所帮助。
It's definitely possible. Here is a start:
Icon overlap http://up.stevetjoa.com/iconoverlap.png
In this example, the icon's position was not defined in terms of the plot's (x,y) coordinates; maybe someone else can help with that. Nevertheless, I hope this example is helpful.
请参阅海豚示例 - 最初是一个笑话,但它展示了如何在不同坐标的图中添加矢量图形。
See the dolphin example — originally a joke, but it shows how to add vector graphics in plots at various coordinates.
晚了很多年,但供将来参考。
我发现添加一个带有
OffsetImage
的AnnotationBbox
对我来说很有效。例如,使用
xy
和xybox
值在绘图内移动图像。进一步阅读可能有用的内容:
http://matplotlib.org/examples/pylab_examples/demo_annotation_box.html
https:// /developer.ibm.com/clouddataservices/2016/10/06/your-own-weather-forecast-in-a-python-notebook/
Many years late but for future reference.
I found that adding an
AnnotationBbox
with anOffsetImage
in it, did the trick for me. e.g.Move the image about within the plot with
xy
andxybox
values.Further reading that may be useful:
http://matplotlib.org/examples/pylab_examples/demo_annotation_box.html
https://developer.ibm.com/clouddataservices/2016/10/06/your-own-weather-forecast-in-a-python-notebook/