简体   繁体   English

Matplotlib 错误:“图形包括与紧密布局不兼容的轴”

[英]Matplotlib Error: "figure includes Axes that are not compatible with tight_layout"

After adding添加后

bbox_inches="tight"

to an invocation of plt.savefig that has worked for several years, I get调用plt.savefig已经工作了几年,我得到

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

This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect此图包含与 tiny_layout 不兼容的 Axes,因此其结果可能不正确

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?我应该在我的代码中寻找一些已知的或常见的原因吗?

In my experience, plt.tight_layout doesn't always work but plt.savefig('fig.png',bbox_inches='tight') does.根据我的经验, plt.tight_layout并不总是有效,但plt.savefig('fig.png',bbox_inches='tight')可以。 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.此外,使用后者后您不需要前者,我在对其进行了一些相当广泛的测试后得出了结论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM