Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Axes.cla() resets axis label position of twin axes #28846

Open
@StefRe

Description

@StefRe

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:

1

Expected outcome

The expected outcome was produced by addingax2.yaxis.set_label_position('right') to the loop:

1

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp