Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: Stop tight layout collapsing under zoom#11742

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedJul 23, 2018
edited
Loading

PR Summary

Fixes#11737, and supersedes#11739

We are now consulting all axes children when doingget_tightbbox (my fault:#10682), including spines. There is some sort of problem with spines not having there transform set before draw when zoom is being used, and this leads to impossible bbox calculations. (See#11627).

This PR adopts the same soln as#11627 and disablestight_layout while zoom and pan are active. This will keep the axes the same size during interactive use, which to my mind is preferable to having the axes change size all the time. However, others may disagree w that.

This PR also has failingtight_layouts just refuse to update the axes positions, whereas before they drew a collapsed axes. Again, in my opinion, drawing something reasonable is better than drawing something that is broken.

importnumpyasnpimportmatplotlib.pyplotaspltfig,ax=plt.subplots()fig.set_tight_layout(True)plt.show()

And use the GUI to zoom. Before this PR, the axes collapsed. Now the axes doesn't change at all because zoom is active.

Note it might be nice to consider when "Zoom" is turned off to trigger a draw, then CL and TL can be made to work.

Of course the original problem is that the transform of the spines is not being set early enough. Not really sure what the soln to that is.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymakjklymakforce-pushed thefix-stop-tight-layout-collapse branch fromdbe6dbc to70e7d18CompareJuly 23, 2018 02:46
@fredrik-1
Copy link
Contributor

fredrik-1 commentedJul 23, 2018
edited
Loading

I don't like this fix but I don't know any really good solution.

It break my usual work process and I believe that the behavior is going to feel strange and inconsistent. Labels are going to be clipped sometimes when zooming and the figure is not going to update as expected if you happen to have clicked the zoom button (I believe that I usually has the zoom button active most of the time) and this could be really confusing.

I believe thattight_layout=True haven't worked as expected and that#10989 was a similar problem. The problem just became much more obvious when the spines where included in thetight_layout calculation.

I believe that a better solution would be to ignore the spines whentight_layout=True. That would probably get the same behavior as in 2.2.2. I updated#11739 to just be used withtight_layout=True

@fredrik-1fredrik-1 mentioned this pull requestJul 23, 2018
6 tasks
@jklymak
Copy link
MemberAuthor

It break my usual work process and I believe that the behavior is going to feel strange and inconsistent. Labels are going to be clipped sometimes when zooming and the figure is not going to update as expected if you happen to have clicked the zoom button (I believe that I usually has the zoom button active most of the time) and this could be really confusing.

Yes, thats correct - when the zoom button is active the axes resizing will stop. I think its pretty arguable whether the axes size should jump around while zooming.

An alternative approach is to take the spines out of the layout process for tight layout only by setting them manually to not be in the layout :set_in_layout(False). Thats preferable to just taking spines out for any use ofget_tightbbox. If you just remove spines thensavefig(bbox='tight') won't work anymore for spines that are significantly displaced from their axes.

@fredrik-1
Copy link
Contributor

Yes, thats correct - when the zoom button is active the axes resizing will stop. I think its pretty arguable whether the axes size should jump around while zooming.

I believe that it is the exact behavior that you want if you useset_tight_layout(True). The axes usually don't jump around that much that it seems strange either.

@jklymakjklymakforce-pushed thefix-stop-tight-layout-collapse branch from70e7d18 tod636914CompareJuly 23, 2018 13:48
@jklymak
Copy link
MemberAuthor

OK, this version just takes spines out of the layout if tight_layout is called. The only drawback is that they willstill be taken out forsavefig(bbox='tight')

@jklymakjklymakforce-pushed thefix-stop-tight-layout-collapse branch fromd636914 tod95d80dCompareJuly 23, 2018 13:50
@jklymak
Copy link
MemberAuthor

Closing for#11754

@jklymakjklymak deleted the fix-stop-tight-layout-collapse branchJuly 23, 2018 19:47
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug in tight_layout
2 participants
@jklymak@fredrik-1

[8]ページ先頭

©2009-2025 Movatter.jp