-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Axes.cla() resets axis label position of twin axes #28846
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 guess an straightforward fix would be to restore the label position after clearing the axis: matplotlib/lib/matplotlib/axes/_base.py Lines 1273 to 1274 in a254b68
by changing line 1274 to old_label_position = axis.label_position
axis.clear()
axis.label_position = old_label_position |
or better do it in Axis.clear() around: matplotlib/lib/matplotlib/axis.py Line 892 in a254b68
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug summary
I'm making many plots in a loop using the same Figure and Axes. The basic setup including a twin Axes is done once and the Axes are cleared at the end of the loop using
cla()
.Axes.cla()
resets the label position of theyaxis
of the twin Axes to the default (left), resulting in misplaced ylabels in all but the first loops.Ticks and tick labels of the left y axis are kept at the correct side, so I would the axis label also expect to be kept at the correct side.
Code for reproduction
Actual outcome
1.png:
Expected outcome
The expected outcome was produced by adding
ax2.yaxis.set_label_position('right')
to the loop:Additional information
No response
Operating system
No response
Matplotlib Version
3.9.2
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
The text was updated successfully, but these errors were encountered: