-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: y_label in wrong place after clearing for twinx axes #28268
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
Comments
I noticed the same problem using FigureCanvasQTAgg in an app I'm working. Version 3.7.0 and up all have this problem - I tested 3.7.0, 3.7.3, 3.8.3, and 3.9.0. In previous versions (I tested 3.5.1 and 3.6.3) the second y label remains on the correct side after clearing the axes and plotting. |
Hi! Is this bug still present? In case I could work on it |
The bug is present and there's an open pull request #28325. If you want to contribute, please start from there. In particular, it should be analyzed which aspects of twinned axes are reset and which are already kept under |
Perfect, I got your point! I'll start working on it. Many thanks |
In my opinion "clear" is not too mysterious - it puts the axes in the pristine state that Matplotlib creates it in. The difficulty here is that from the users point of view, Matplotlib creates the twin axes with the labels on the opposite side of a normal axes. To me, that says we should return to the user a slightly modified axes subclass that explicitly swaps the default axes position. |
I'm not sure this solves all clear topics, but making a TwinAxes with dedicated semantics and an overwritten clear() method seems reasonable. |
Bug summary
After making sexond axes on the righr with twinx y_label for this second axes is on the right, but clearing (doesn't matter is it cla() or clear()) second axes breaks set_ylabel putting it on the left. Ticks for second axes are still on the right, so I don't see why y_label wouldn't also go there (thats why I think its a bug)
Code for reproduction
Actual outcome
Expected outcome
after clearing ax2 is still on the right, I expected its label also to be on the right

Additional information
I saw that similar solved problems occurred with twinx()(it was something to do with mirroring), but I couldn't find solution for this specific situation
Operating system
No response
Matplotlib Version
3.7.1
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
The text was updated successfully, but these errors were encountered: