Matplotlib Error: “figure includes Axes that are not compatible with tight_layout”

∥☆過路亽.° 提交于 2019-12-18 12:09:48

问题


After adding

bbox_inches="tight"

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: UserWarning:

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?


回答1:


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



来源:https://stackoverflow.com/questions/35393863/matplotlib-error-figure-includes-axes-that-are-not-compatible-with-tight-layou

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!