-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Bind subplot_tool more closely to target figure. #21681
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You sniped me on this PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I click on the subplot tool using the qt5agg backend, it immediately looks like it clears the figure. Somehow the values for the left/right adjustment are getting set to near zero.
I combined this with #21663 and it worked like a charm on the macosx backend!
One other request would be to add a test for this. Something that adds the subplot adjust window, then closes the main figure and asserts there is nothing left in the manager so we can be sure we're keeping this behavior in the future.
- More the implementation to backend_bases and have pyplot read it, rather than having backend_bases fetch it from pyplot, which was a bit weird. - Attach the subplot_tool to the toolbar, which avoids having to keep a reference to it (when calling plt.subplot_tool), and prevents opening two subplot_tools for the same figure. On most backends, closing the subplot_tool deletes the reference, because reopening a closed figure seems not guaranteed to work; on Qt, which has its own subplot_tool, reopening the closed QDialog does work, so just reuse it. - Ensure that closing the main figure also closes the subplot_tool.
Fixed the bug with qt. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there were no tests before, so this is fine if there is not a trivial way of doing it. I just tested with macosx and qt5agg and it works as expected for me now.
@meeseeksdev backport to v3.5.x |
…681-on-v3.5.x Backport PR #21681 on branch v3.5.x (Bind subplot_tool more closely to target figure.)
rather than having backend_bases fetch it from pyplot, which was a
bit weird.
a reference to it (when calling plt.subplot_tool), and prevents
opening two subplot_tools for the same figure. On most backends,
closing the subplot_tool deletes the reference, because reopening a
closed figure seems not guaranteed to work; on Qt, which has its own
subplot_tool, reopening the closed QDialog does work, so just reuse
it.
([MNT]: Close subplot_parameters window when main figure closes #21679, the main motivation for this PR.)
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).