0
我想用matplotlib
生成一个多图,并在每个子图的角落中嵌入图像。Matplotlib:在几个子图中嵌入图像()
我已经能够使用following example of the matplotlib documentation(代码如下)在(单个)情节图中嵌入图像。
我现在试图将图像嵌入到一系列子图的每一个的角落。我似乎无法找到类似于我之前示例所依赖的图的add_axes()
的功能。
我怎样才能达到理想的布局?
import pylab as plt
from numpy import linspace
from matplotlib.cbook import get_sample_data
from scipy.misc import imread
xs = linspace(0, 1, 100)
def single_plot():
fig, ax = plt.subplots()
ax.plot(xs, xs**2)
fn = get_sample_data("grace_hopper.png", asfileobj=False)
image_axis = fig.add_axes([0.65, 0.70, 0.3, 0.2], anchor='NE', zorder=10)
image_axis.imshow(imread(fn))
plt.show()
plt.clf()
def multi_plot():
fig, axes = plt.subplots(4)
for axis in axes:
axis.plot(xs, xs**2)
# How to draw the same image as before in the corner of each subplot ?
plt.show()
if __name__ == '__main__':
single_plot()
multi_plot()
@伯特兰 - 卡隆如果答案解决你的问题,请考虑[接受它作为一个解决方案(http://stackoverflow.com/help /有人-答案)。 – Brian