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

Commitddf33cd

Browse files
committed
FIX: move twins when moving parents
1 parent1999228 commitddf33cd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,10 +1061,12 @@ def set_position(self, pos, which='both'):
10611061
matplotlib.transforms.Bbox.from_bounds
10621062
matplotlib.transforms.Bbox.from_extents
10631063
"""
1064-
self._set_position(pos,which=which)
1065-
# because this is being called externally to the library we
1066-
# don't let it be in the layout.
1067-
self.set_in_layout(False)
1064+
foraxinself._twinned_axes.get_siblings(self):
1065+
ax._set_position(pos,which=which)
1066+
# because this is being called externally to the library we
1067+
# don't let it be in the layout.
1068+
ax.set_in_layout(False)
1069+
10681070

10691071
def_set_position(self,pos,which='both'):
10701072
"""

‎lib/matplotlib/tests/test_axes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,18 @@ def test_twinx_axis_scales():
399399
ax2.margins(0,0)
400400

401401

402+
@pytest.mark.parametrize('twin', ('x','y'))
403+
deftest_twin_moved(twin):
404+
fig,ax=plt.subplots()
405+
# test twinx or twiny
406+
ax_twin=getattr(ax,f'twin{twin}')()
407+
ax.set_position([0.2,0.2,0.5,0.5])
408+
fig.draw_without_rendering()
409+
410+
assert_array_equal(ax.bbox.extents,
411+
ax_twin.bbox.extents)
412+
413+
402414
deftest_twin_inherit_autoscale_setting():
403415
fig,ax=plt.subplots()
404416
ax_x_on=ax.twinx()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp