-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
figure.clf() and subplots_adjust #11059
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
I'm not sure if this is intended behaviour or not. If understand what you are describing, it seems like There is a tension in the docs between reproducibility and simplicity. See the |
A crazy way to reset the subplotpars to the rcParams' values would be
...probably not the recommended way.
So given that those are really suboptimal "solutions", I think it would be good to
|
I added two labels because
|
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
The first and most important thing to do here is define what "clear" means for a figure. To do that, we should identify the use case ("Why clear and reuse a figure instead of just creating a new one?"). I see the main application when the figure is embedded in an application and you want to update the plot. Therefore:
I'm undecided on (and believe they are currently not reset):
Whether they should be reset or not depends on how similar / different the new plot is. One can argue that these are similar fundamental visual properties like figure size and thus should not be reset. OTOH if the new should look substantially different, it's cumbersome to reset these manually. |
This might not be a bug but I doubt that it is an intended behavior.
figure.clf()
don't change the subplot parameters to any default values so it is not enough to dofigure.clf()
when testing to plot with or without for exampletight_layout
. This is easy to fix by adding for example:to figure.clf()
When I looked into this I also found that the docstrings for
subplots_adjust
andSubplotParams
are kind of confusing and not really correct. The default is, except inSuplotParams.__ini__
(that most people probably newer use directly), not the rc parameters that it seems but the actual attributes in theSuplotParams
object. So it is not trivial to start all over with the default rc variables after a change in the subplotparameters by for example tight_layout.The documentation should probably be changed anyway. Are there any method to avoid writing almost the same things several times?
figure.subplots_adjust
andplt.subplots_adjust
should have more or less the exact same docstring and theSuplotParams
should also have a similar one.The text was updated successfully, but these errors were encountered: