Matplotlib错误:“图包括与tight_layout不兼容的轴"; [英] Matplotlib Error: "figure includes Axes that are not compatible with tight_layout"

查看:53
本文介绍了Matplotlib错误:“图包括与tight_layout不兼容的轴";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加后

bbox_inches="tight"

调用已经工作了几年的 plt.savefig,我得到

to an invocation of plt.savefig that has worked for several years, I get

/usr/local/lib/python2.7/site-packages/matplotlib/figure.py:1744:用户警告:

/usr/local/lib/python2.7/site-packages/matplotlib/figure.py:1744: UserWarning:

这个数字包括与tight_layout不兼容的Axes,所以它的结果可能不正确

This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect

有问题的数字似乎有效(现在没有注释截断),但我想知道这个错误可能意味着什么以及是否有任何明显的或已知的(无需深入研究复杂的图形代码)可以解决这个问题.

The figure in question appears to work (without truncation of annotations now), but I wonder what this error could mean and whether there's anything obvious or known (without digging deep into complex figure code) that I can do to address it.

我应该在代码中寻找一些已知或常见的原因吗?

Is there some known or common cause for this that I should look for in my code?

推荐答案

根据我的经验,plt.tight_layout 并不总是有效,但 plt.savefig('fig.png',bbox_inches='tight') 确实如此.此外,在使用了后者之后,您不需要前者,而在对它进行了相当广泛的测试之后,我得出了结论.

In my experience, plt.tight_layout doesn't always work but plt.savefig('fig.png',bbox_inches='tight') does. In addition, you don't need the former after using the latter and I have come to the conclusion after some pretty extensive testing of it.

这篇关于Matplotlib错误:“图包括与tight_layout不兼容的轴";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆