-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Should constrained_layout be applied every draw? #11630
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
Comments
It may be worth making the behavior configurable. As you said, there are use-cases for both scenarios. |
I have a crazy idea: tight_layout can be called from within the GUI Would it make sense to add another button for constrained_layout? This would be a toggle button - as long as it is active constrained_layout will take effect, but you may toggle it off as well. Not sure what the default state would be though. |
Would it affect animations? Like for each frame that is shown contrained_layout is called? I think that would be completely undesired. |
@ImportanceOfBeingErnest and @timhoffm Thanks for your thoughts... First, Programatically, we can turn off We could have an @afvincent was talking about the layout GUI in another thread. I think it'd make sense for the GUI to be different if WRT animations: definitely, constrained_layout will cause the axes to be resized while animating. Again, the current solution is to draw the first draw w/ constrained_layout on, and then call |
So that button would only appear if you created the figure with contrained_layout turned on.
Sounds like this needs a chapter in the constrained_layout guide. |
Discussion
Right now
fig, ax = plt.subplots(constrained_layout=True)
will cause the axes resizing to be carried out every draw event; hence the axes get repositioned if the figure changes size, or if zoom is applied, or panning, etc.Is this desirable?
plt.tight_layout()
is only called once, and does not get activated at draw time.Pros:
Cons:
Any opinions? For my usual workflow, I'm probably fine with just calling constrained layout on the original plot. Any zooming etc are done on working plots versus final presentation plots, and I hard code limits in after the exploration stage. But I get the feeling some people use a lot of GUI work before saving their plots.
The text was updated successfully, but these errors were encountered: