在 Matplotlib/Python 中将小照片/图像添加到大图中 [英] Adding a small photo/image to a large graph in Matplotlib/Python

查看:40
本文介绍了在 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

谢谢

推荐答案

这绝对是可能的.这是一个开始:

It's definitely possible. Here is a start:

import matplotlib, scipy
fig = matplotlib.figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
axicon = fig.add_axes([0.4,0.4,0.1,0.1])
ax.plot(range(5), [4,2,3,5,1])
axicon.imshow(scipy.randn(100,100))
axicon.set_xticks([])
axicon.set_yticks([])
fig.show()

图标重叠 http://up.stevetjoa.com/iconoverlap.png

在此示例中,未根据图的(x,y)坐标定义图标的位置;也许其他人可以帮助您.不过,我希望这个例子有帮助.

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.

这篇关于在 Matplotlib/Python 中将小照片/图像添加到大图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆