Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix issue with clf not clearing constrainedlayout #10552

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

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Feb 21, 2018

PR Summary

As noted by @afvincent (on gitter)

import matplotlib.pyplot as plt

#import matplotlib as mpl
#print(mpl.__version__)  #  --> 2.2.0rc1

plt.ion()  # --> no warning without it

fig = plt.figure(num=1,
                clear=True, #--> no effect on the warnin
                constrained_layout=True)
ax = fig.subplots()
ax.plot([1, 2])

if called twice in an interactive session doesn't work on master.

The new axis is still being constrained by the presence of the old (cleared) one and gets shrunk to nothing.

This change properly resets the constrained_layout mechanism when figure.clf() is called.

@jklymak jklymak added this to the v2.2.0 milestone Feb 21, 2018
@afvincent
Copy link
Contributor

afvincent commented Feb 21, 2018

@jklymak I just tried locally your PR and it looks like I now get the behavior that I was expecting in the first place :): no warning with clear=True, and the behavior that you described above with clear=False.

Edit: Unfortunately CI seems a bit less happy than I am :/...

@jklymak
Copy link
Member Author

jklymak commented Feb 21, 2018

Yep. Testing is good. I was being too aggressive in re-instantiating the layoutbox; the gridspec actually instantiates the figure's layoutbox...

@jklymak jklymak added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: geometry manager LayoutEngine, Constrained layout, Tight layout labels Feb 21, 2018
@jklymak
Copy link
Member Author

jklymak commented Feb 21, 2018

Appveyor seems backlogged, but other tests seem fine now

@tacaswell tacaswell merged commit 9b48fd8 into matplotlib:master Feb 21, 2018
dstansby added a commit that referenced this pull request Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants