Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
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 usingcla()
.
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
importmatplotlib.pyplotaspltfig,ax1=plt.subplots()ax2=ax1.twinx()foriinrange(2):# do some plotting hereax2.set(ylabel=f'ylabel of plot #{i}',ylim=(1,i+2))fig.savefig(f'{i}.png')ax1.cla()ax2.cla()
Actual outcome
1.png:
Expected outcome
The expected outcome was produced by addingax2.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
Metadata
Metadata
Assignees
Labels
No labels