-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: Don't apply tight_layout if axes collapse #12285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FIX: Don't apply tight_layout if axes collapse #12285
Conversation
Can you document that as an API change? Put it directly in |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document that get_tight_layout_figure()
can now return None
as well.
@timhoffm - is the new commit what you were after? Thanks! |
Flake8 says
|
Thanks! Evil trailing space eradicated.... |
a250c85
to
a58ce76
Compare
Thanks @jklymak ! Your work to make sure the tight/constrained layout works well is greatly appreciated! |
PR Summary
Partially addresses #12256
If tight_layout is called and there is an annotation or legend that is outside the axes, it can sometimes happen that the axes completely collapses. There is currently a warning, but this PR also doesn't apply tight_layout if that happens, under the assumption its better to draw something rather than draw something that is completely broken.
Note however, it is still possible for the axes to get quite small.
The origin of these issues is that
axes.get_tightbbox
now includes all artists when computing the bounding box, whereas before 3.0 it only included the axes elements themselves, and none of the artists. Now artists can be excluded by explictly settinga.set_inlayout(False)
.NOTE: this is an API change in that
tight_layout.auto_adjust_subplotpars
now can return None if no good subplotpars were computed.PR Checklist