You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify that constrained_layout and tight_layout conflict with each other #17339
Thats not particularly the problem here; constrained_layout is a bit of a red herring. tight_layout just doesn't know about the big colorbar so ignores it. In the code above constrained_layout=True is ignored because tight_layout gets precedence (simply because its older).
If tight_layout and constrained_layout are not compatible, it would useful to have it documented - I can do this at some point.
Regardless of using constrained_layout or not, can you confirm the following: if I understand correctly, the colorbar is ignored by tight_layout because it is an instances of matplotlib.axes._axes.Axes and not matplotlib.axes._subplots.AxesSubplot?
Its says constrained_layout is to be used instead of tight_layout in quite a few places. They are not incompatible per se, just tight_layout cancels out constrained_layout.
changed the title [-]Colorbar ignored when calling tight_layout[/-][+]Clarify that constrained_layout and tight_layout conflict with each other[/+]on May 7, 2020
/tmp/pyIDWTj1:8: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
/tmp/pyIDWTj1:8: UserWarning: This figure was using constrained_layout==True, but that is incompatible with subplots_adjust and or tight_layout: setting constrained_layout==False.
This limitation of tight_layout was one of the motivations for writing constrained layout. I think action items here are:
add a sentance to the top indicating that constrained layout and tight layout are alternatives
Thanks for the explanations!
In the documentation, it is mentioned that both are alternatives but it is not clear, which one would be more useful. Even if there are many examples, it is not straightforward to work out which one would be more appropriate/robust. Maybe also add some simple guidelines or rule of thumb to the documentation?
Activity
jklymak commentedon May 6, 2020
Yes, thats expected, or at least understood. You can use
constrained_layoutinstead...Edit: tight_layout and constrained_layout are not compatible.
QuLogic commentedon May 6, 2020
Maybe we should raise if calling
tight_layoutwhen the figure hasconstrained_layoutenabled?jklymak commentedon May 6, 2020
Thats not particularly the problem here; constrained_layout is a bit of a red herring.
tight_layoutjust doesn't know about the big colorbar so ignores it. In the code aboveconstrained_layout=Trueis ignored becausetight_layoutgets precedence (simply because its older).QuLogic commentedon May 7, 2020
Does that generate a warning then?
ericpre commentedon May 7, 2020
If
tight_layoutandconstrained_layoutare not compatible, it would useful to have it documented - I can do this at some point.Regardless of using
constrained_layoutor not, can you confirm the following: if I understand correctly, the colorbar is ignored bytight_layoutbecause it is an instances ofmatplotlib.axes._axes.Axesand notmatplotlib.axes._subplots.AxesSubplot?jklymak commentedon May 7, 2020
Its says
constrained_layoutis to be used instead oftight_layoutin quite a few places. They are not incompatible per se, just tight_layout cancels out constrained_layout.We could raise a warning I suppose.
[-]Colorbar ignored when calling tight_layout[/-][+]Clarify that constrained_layout and tight_layout conflict with each other[/+]tacaswell commentedon May 7, 2020
At least on master we do warn:
This limitation of
tight_layoutwas one of the motivations for writing constrained layout. I think action items here are:tight_layoutbreaking this example.ericpre commentedon May 7, 2020
Thanks for the explanations!
In the documentation, it is mentioned that both are alternatives but it is not clear, which one would be more useful. Even if there are many examples, it is not straightforward to work out which one would be more appropriate/robust. Maybe also add some simple guidelines or rule of thumb to the documentation?
5 remaining items
DOC: Recommend constrained_layout over tight_layout
DOC: Recommend constrained_layout over tight_layout (#29584)