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

Skip to content

FIX: do not warn when calling tight_layout multiple times #26300

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
Jul 13, 2023

Conversation

tacaswell
Copy link
Member

PR summary

Closes #26290

I was between adding state to the PlaceHolder layout enigne and holding that state via a no-op sub-class. Ended up going for the second, but could see the case for the first.

PR checklist

@rcomer
Copy link
Member

rcomer commented Jul 13, 2023

Would it be enough to not warn when the existing layout engine is any placeholder layout engine? My understanding is that the warning is aimed at users who set up a figure with compressed/constrained layout and do not realise tight_layout is incompatible (or who copy-pasted some old code and neglected to strip out the tight_layout call). #24528

If you have a placeholder, I think you must already have turned the layout engine off somewhere.

@tacaswell
Copy link
Member Author

I was worried about the case of

fig = plt.figure(layout='constrained')
fig.set_layout_engine('none')
fig.tight_layout()     # <- should this warn?!

I went with "yes" on reflex but on a bit more consideration, I think "no" may be a better answer as by explicitly clearing the layout engine the user as already opted out of the automatic calls and are doing it "manually".

@tacaswell tacaswell force-pushed the fix/multiple_tightlayout branch from 18e19b3 to f7574a4 Compare July 13, 2023 15:11
@jklymak jklymak merged commit 6391678 into matplotlib:main Jul 13, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jul 13, 2023
@tacaswell tacaswell deleted the fix/multiple_tightlayout branch July 13, 2023 20:08
@QuLogic QuLogic added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label Jul 13, 2023
tacaswell added a commit that referenced this pull request Jul 13, 2023
…300-on-v3.7.x

Backport PR #26300 on branch v3.7.x (FIX: do not warn when calling tight_layout multiple times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: calling fig.tight_layout multiple times
4 participants