-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix issue with shared x-axis resetting when calling cla() on shared axes #28697
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
This is a dupliate. The approach was suggested in the original issue and the poster already made a PR (#28101). Discussion should continue in that PR. |
@ydotwang thanks for the interest. It's currently not possible to write a test. The solution of mutually sharing Axes would solve the concrete issue, however it would introduce other issues. The proper way forward is laid out in #28101 (comment), but it's a non-trivial rearchitecturing. Tests will need to be written in the process of that migration. |
Thank you for your answer! |
PR summary
Fix bidirectional axis sharing in sharex, sharey, and __clear methods
Description:
This pull request addresses issues related to the handling of shared axes (sharex and sharey) in Matplotlib, particularly in scenarios involving clearing of axes.
Summary of Changes:
Bidirectional Sharing:
The sharex and sharey methods have been updated to ensure bidirectional sharing of axes. Previously, when axis A shared its x-axis with axis B, changes to B would not affect A. This has been corrected by ensuring that B also shares its x-axis back with A.
Impact:
These changes resolve the issue where shared axes would not behave symmetrically, leading to unexpected behavior when clearing axes or working with inverted axes. The updates ensure consistent and predictable behavior in shared axes scenarios.
Before PR:

After PR:

Testing:
Existing tests related to shared axes should be reviewed to ensure they cover these scenarios. New tests can be added to specifically verify bidirectional sharing and correct inversion handling during clearing.
This pull request ensures that Matplotlib handles shared axes in a robust manner, improving the overall user experience when working with subplots and synchronized axes.
PR checklist