調整插曲佈局我才明白,matplotlib的tight_layout()
不能應用於由大熊貓產生的地塊。與大熊貓
這是我運行的代碼:我結束了以下錯誤
0 1 2 3 4
A 0.039895 0.960105 NaN NaN NaN
D 0.030418 0.969582 NaN NaN NaN
E 0.037345 0.962655 NaN NaN NaN
F 0.061522 0.938478 NaN NaN NaN
G 0.047163 0.952837 NaN NaN NaN
H 0.026423 0.000000 0.000000 0.973577 NaN
df.T.plot(kind='bar', subplots=True, width=0.7, legend=False,
layout=(2,4), sharex=True, sharey=True)
plt.tight_layout()
:
AttributeError: 'NoneType' object has no attribute 'is_bbox'
我也認爲,這是關係到張貼在github上一個類似的問題: DataFrame.hist() does not get along with matplotlib.pyplot.tight_layout() #9351
因此,我正在尋找一個基於subplots_adjust(*args, **kwargs)
的解決方法。最重要的是,我試圖調整hspace
參數。但是,在調用pandas的plot
函數時,不接受這些關鍵字參數。
有什麼建議嗎?
您可以發佈產生錯誤的代碼。也就是說,你怎麼叫plt。如果您沒有任何子插槽(即使它只有一個子插槽),則無法調用subplots_adjust()方法。 –