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]: twinx and twiny ignores previous set_position #21409

@bfield1

Description

@bfield1

Bug summary

If I manually set the position of an Axes, then call twinx or twiny, the new twinned Axes appears in the original position of the parent Axes, not in the new position.

Code for reproduction

importmatplotlib.pyplotaspltfig,ax=plt.subplots()ax.set_position([0.2,0.2,0.5,0.5])ax2=ax.twinx()plt.show()

Actual outcome

MPL_Bug_Image

I note thatax.get_position(original=True) andax.get_position(original=False) both give the same answer.
I also note that the same issue occurs forax.twiny().

Expected outcome

MPL_Bug_Expected
This expected outcome can be obtained by adding the line

ax2.set_position(ax.get_position())

after callingax2=ax.twinx(). Alternatively, it can be obtained by callingax.set_position after callingax.twinx.
However, I would expecttwinx to automatically inherit the position of the parent Axes, rather than draw the new Axes in an unrelated location.

Operating system

Windows 10

Matplotlib Version

3.4.2

Matplotlib Backend

TkAgg

Python version

3.9.4

Jupyter version

No response

Other libraries

No response

Installation

pip

Conda channel

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp