1
雖然繪製數據幀:熊貓情節savefig,不使用bbox_inches控制幀大小=「緊」
d_f.plot()
plt.savefig(image.png, bbox_inches='tight')
bbox_inches='tight'
可用於在最終.PNG大幅除去了很多幀的(空白)圖片。
是可以減少一點的框架?
雖然繪製數據幀:熊貓情節savefig,不使用bbox_inches控制幀大小=「緊」
d_f.plot()
plt.savefig(image.png, bbox_inches='tight')
bbox_inches='tight'
可用於在最終.PNG大幅除去了很多幀的(空白)圖片。
是可以減少一點的框架?
bbox_inches='tight'
或plt.tight_layout
都是自動的。
您應該使用plt.subplots_adjust()代替:
ax = df[['y','w']].plot()
fig = ax.get_figure()
left = 0.125 # the left side of the subplots of the figure
right = 0.9 # the right side of the subplots of the figure
bottom = 0.1 # the bottom of the subplots of the figure
top = 0.9 # the top of the subplots of the figure
wspace = 0.2 # the amount of width reserved for blank space between subplots
hspace = 0.2 # the amount of height reserved for white space between subplots
# These two can be called on 'fig' instead of 'plt' too
plt.subplots_adjust(left=left, bottom=bottom, right=right, top=top,
wspace=wspace, hspace=hspace)
plt.savefig('image.png')
如果你想有沒有留下什麼空間,設置left=0
,如果你想沒有空間上擺正right=1
。
下面是對沒有留下任何空間和大量的右側與facecolor設置爲紅色,一個誇張的例子,所以我們可以清楚地看到:
fig.subplots_adjust(left=left, bottom=bottom, right=right, top=top,
wspace=wspace, hspace=hspace)
plt.savefig('image.png', facecolor='red')