Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

/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?

like image 720
orome Avatar asked Feb 14 '16 16:02

orome


1 Answers

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.

like image 77
jimh Avatar answered Sep 22 '22 21:09

jimh