首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >熊猫不使用bbox_inches=“紧”控制帧大小

熊猫不使用bbox_inches=“紧”控制帧大小
EN

Stack Overflow用户
提问于 2016-11-22 00:34:42
回答 1查看 766关注 0票数 1

在绘制数据帧时:

代码语言:javascript
复制
d_f.plot()
plt.savefig(image.png, bbox_inches='tight')

bbox_inches='tight'可用于彻底删除最终.png图像中的许多帧(空白)。

是可以减少一点点的框架吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-22 00:56:22

bbox_inches='tight'plt.tight_layout都是自动的。

您应该使用调整()来代替:

代码语言:javascript
复制
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

下面是一个夸张的例子,左边没有空格,右边有很多地方,面部颜色设置为红色,这样我们就可以清楚地看到:

代码语言:javascript
复制
fig.subplots_adjust(left=left, bottom=bottom, right=right, top=top,
            wspace=wspace, hspace=hspace)
plt.savefig('image.png', facecolor='red')

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40731938

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档