1
使用tight_layout(h_pad = -1)更改兩個子圖之間的垂直距離可更改總圖形大小。我如何使用tight_layout定義圖形大小?子圖:tight_layout更改圖大小
下面是代碼:
#define figure
pl.figure(figsize=(10, 6.25))
ax1=subplot(211)
img=pl.imshow(np.random.random((10,50)), interpolation='none')
ax1.set_xticklabels(()) #hides the tickslabels of the first plot
subplot(212)
x=linspace(0,50)
pl.plot(x,x,'k-')
xlim(ax1.get_xlim()) #same x-axis for both plots
這裏是結果:
如果我寫
pl.tight_layout(h_pad=-2)
在最後一行
,然後我得到這樣的:
正如你所看到的,這個數字是大...
我想這就是答案,但unfortunatley fig.tight_layout仍然改變數字大小。您可以通過打開和關閉fig.tight_laout來測試它:fig = pl.figure(figsize =(10,6.25)) pl.imshow(np.random.random((10,50)),interpolation ='none' ) #fig.tight_layout(h_pad = 0) – FrankTheTank