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

FIX: move twins when moving parents#22817

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jklymak wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromjklymak:fix-moved-twin
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1061,10 +1061,11 @@ def set_position(self, pos, which='both'):
matplotlib.transforms.Bbox.from_bounds
matplotlib.transforms.Bbox.from_extents
"""
self._set_position(pos, which=which)
# because this is being called externally to the library we
# don't let it be in the layout.
self.set_in_layout(False)
for ax in self._twinned_axes.get_siblings(self):
ax._set_position(pos, which=which)
# because this is being called externally to the library we
# don't let it be in the layout.
ax.set_in_layout(False)

def _set_position(self, pos, which='both'):
"""
Expand Down
12 changes: 12 additions & 0 deletionslib/matplotlib/tests/test_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -399,6 +399,18 @@ def test_twinx_axis_scales():
ax2.margins(0, 0)


@pytest.mark.parametrize('twin', ('x', 'y'))
def test_twin_moved(twin):
fig, ax = plt.subplots()
# test twinx or twiny
ax_twin = getattr(ax, f'twin{twin}')()
ax.set_position([0.2, 0.2, 0.5, 0.5])
fig.draw_without_rendering()

assert_array_equal(ax.bbox.extents,
ax_twin.bbox.extents)


def test_twin_inherit_autoscale_setting():
fig, ax = plt.subplots()
ax_x_on = ax.twinx()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp