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

Skip to content

Commit 009415f

Browse files
committed
FIX: correctly unset the layout engine in Figure.tight_layout
closes #7805
1 parent 8ca75e4 commit 009415f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None):
35153515
and previous_engine is not None:
35163516
_api.warn_external('The figure layout has changed to tight')
35173517
finally:
3518-
self.set_layout_engine(None)
3518+
self.set_layout_engine('none')
35193519

35203520

35213521
def figaspect(arg):

lib/matplotlib/tests/test_figure.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,15 @@ def test_invalid_layouts():
659659
fig.set_layout_engine("constrained")
660660

661661

662+
@check_figures_equal(extensions=["png"])
663+
def test_tightlayout_autolayout_deconfilct(fig_test, fig_ref):
664+
for fig, autolayout in zip([fig_ref, fig_test], [False, True]):
665+
with mpl.rc_context({'figure.autolayout': autolayout}):
666+
axes = fig.subplots(ncols=2)
667+
fig.tight_layout(w_pad=10)
668+
assert isinstance(fig.get_layout_engine(), PlaceHolderLayoutEngine)
669+
670+
662671
@pytest.mark.parametrize('layout', ['constrained', 'compressed'])
663672
def test_layout_change_warning(layout):
664673
"""

0 commit comments

Comments
 (0)