【发布时间】:2013-07-01 18:26:06
【问题描述】:
如果你想在一个更大的图中插入一个小图,你可以使用Axes,比如here。
问题是我不知道如何在子图中做同样的事情。
我有几个子图,我想在每个子图中绘制一个小图。 示例代码将是这样的:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
for i in range(4):
ax = fig.add_subplot(2,2,i)
ax.plot(np.arange(11),np.arange(11),'b')
#b = ax.axes([0.7,0.7,0.2,0.2])
#it gives an error, AxesSubplot is not callable
#b = plt.axes([0.7,0.7,0.2,0.2])
#plt.plot(np.arange(3),np.arange(3)+11,'g')
#it plots the small plot in the selected position of the whole figure, not inside the subplot
有什么想法吗?
提前致谢!
【问题讨论】:
-
正在研究解决方案,我发现另一个问题...stackoverflow.com/questions/17478165/…
-
非常感谢你们两位。正如比尔建议的那样,我可以使用 AxesGrid 中的 zoomed_inset_axis 以及 Pablo 的功能来完成我正在寻找的事情。最后,我使用了 Pablo 的函数,因为它比 AxesGrid 更舒适地在所有子图中绘制所有具有相同大小的小图形。再次感谢!
标签: matplotlib plot embedding axes subplot