私はmatplotlib
でマルチプロットを生成し、私のサブプロットの各コーナーに画像を埋め込むしたいと思います。matplotlibの:いくつかのサブプロットで埋め込み画像()
Iは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