Skip to content

Commit e8df9e5

Browse files
committed
Add test to ensure twin axes remain aligned after tight_layout
1 parent 5876d06 commit e8df9e5

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ def test_twin_keeps_layout_participation_for_layout_managed_axes(twin):
501501
assert ax2.get_in_layout()
502502

503503

504+
@pytest.mark.parametrize("twin", ("x", "y"))
505+
def test_twin_stays_aligned_after_tight_layout(twin):
506+
fig,ax = plt.subplots()
507+
ax2 = getattr(ax, f"twin{twin}")()
508+
509+
fig.tight_layout()
510+
511+
assert_allclose(ax.get_position().bounds, ax2.get_position().bounds)
512+
513+
504514
def test_inverted_cla():
505515
# GitHub PR #5450. Setting autoscale should reset
506516
# axes to be non-inverted.

0 commit comments

Comments
 (0)