2013-12-18 39 views
6

我有3個子圖(3行1列)。我們可以使用fig.subplots_adjust(hspace=0.2)來調整子圖之間的距離。這將改變所有情況下子圖之間的距離。我怎樣纔能有不同的距離之間的情節1(311)&情節2(312),和情節2(312)&情節3(313)?調整matplotlib中兩個子圖之間的距離

回答

7

好問題。試試這個:

from mpl_toolkits.axes_grid1 import make_axes_locatable 

ax1 = plt.subplot2grid((1,1), (0,0)) 
divider = make_axes_locatable(ax1) 
ax2 = divider.append_axes("bottom", size="100%", pad=0.5) 
ax3 = divider.append_axes("bottom", size="100%", pad=1) 

然後你會得到:

enter image description here

+0

哪裏函數'make_axes_locatable'從何而來? –

+0

@DavidZwicker'from mpl_toolkits.axes_grid1 import make_axes_locatable' – Skyler