如果要在較大圖中插入小圖,可以使用Axes,如here。在matplotlib中的子圖中嵌入小圖
問題是我不知道如何在一個子圖內做同樣的事情。
我有幾個小區,我想繪製每個小區內的小劇情。 示例代碼將是這樣的:
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
任何想法?
在此先感謝!
參見[此相關的帖子(http://stackoverflow.com/questions/14589600/matplotlib-insets-in-subplots) – wflynny
的解決方案時,我發現了另一個問題... http://stackoverflow.com/questions/17478165/fig-add-subplot-transform-doesnt-work – Pablo
非常感謝你們倆。我可以按照Bill的建議,使用AxesGrid的zoomed_inset_axis以及Pablo的函數來做我想要的。最後,我使用了Pablo的函數,因爲它比AxesGrid更舒適,可以在所有子圖中繪製所有尺寸相同的小圖。再次感謝! – Argitzen