Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5435b5

Browse files
committed
Address review: preserve original/active positions and fix test + lint
1 parent 88d4ec5 commit a5435b5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4657,8 +4657,10 @@ def _make_twin_axes(self, *args, **kwargs):
46574657
twin.set_zorder(self.zorder)
46584658

46594659
self._twinned_axes.join(self, twin)
4660+
46604661
if not self.get_in_layout():
4661-
twin.set_position(self.get_position())
4662+
twin._set_position(self.get_position(original=True), which="original")
4663+
twin._set_position(self.get_position(original=False), which="active")
46624664

46634665
return twin
46644666

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ def test_twin_respects_position_after_set_position(twin):
484484
ax.set_position([0.2, 0.2, 0.5, 0.5])
485485
ax2 = getattr(ax, f"twin{twin}")()
486486

487-
assert_allclose(ax.bbox.bounds, ax2.bbox.bounds)
487+
assert_allclose(ax.get_position().bounds, ax2.get_position().bounds)
488488

489489

490490
def test_inverted_cla():

0 commit comments

Comments
 (0)