Skip to content

Commit 5a69602

Browse files
committed
FIX
1 parent 8aac613 commit 5a69602

3 files changed

Lines changed: 15 additions & 14 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
subplots_adjust no longer changes layout manager
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Previously, if a user called `~matplotlib.Figure.subplots_adjust`, then
4+
``constrained_layout`` was deactivated; this will no longer happen. If
5+
the user wants `~matplotlib.Figure.subplots_adjust` to have an effect
6+
they need to use a compatible layout engine.

‎lib/matplotlib/figure.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,8 +1147,8 @@ def colorbar(self, mappable, cax=None, ax=None, use_gridspec=True, **kw):
11471147
"to colorbar().")
11481148

11491149
if use_gridspec:
1150-
if (self.layout_engine is not None and
1151-
not self.layout_engine.colorbar_gridspec):
1150+
if (self.get_layout_engine() is not None and
1151+
not self.get_layout_engine().colorbar_gridspec):
11521152
use_gridspec = False
11531153
# Store the value of gca so that we can set it back later on.
11541154
if cax is None:
@@ -2064,6 +2064,9 @@ def get_constrained_layout_pads(self, relative=False):
20642064
"""
20652065
return self._parent.get_constrained_layout_pads(relative=relative)
20662066

2067+
def get_layout_engine(self):
2068+
return self._parent.get_layout_engine()
2069+
20672070
@property
20682071
def axes(self):
20692072
"""

‎lib/matplotlib/tests/test_figure.py‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,6 @@ def test_figure_repr():
505505
assert repr(fig) == "<Figure size 100x200 with 0 Axes>"
506506

507507

508-
def test_warn_cl_plus_tl():
509-
fig, ax = plt.subplots(constrained_layout=True)
510-
with pytest.warns(UserWarning):
511-
# this should warn,
512-
fig.subplots_adjust(top=0.8)
513-
assert not(fig.get_constrained_layout())
514-
515-
516508
@check_figures_equal(extensions=["png", "pdf"])
517509
def test_add_artist(fig_test, fig_ref):
518510
fig_test.set_dpi(100)
@@ -689,8 +681,8 @@ def test_all_nested(self, fig_test, fig_ref):
689681
x = [["A", "B"], ["C", "D"]]
690682
y = [["E", "F"], ["G", "H"]]
691683

692-
fig_ref.set_constrained_layout(True)
693-
fig_test.set_constrained_layout(True)
684+
fig_ref.set_layout_engine("constrained")
685+
fig_test.set_layout_engine("constrained")
694686

695687
grid_axes = fig_test.subplot_mosaic([[x, y]])
696688
for ax in grid_axes.values():
@@ -710,8 +702,8 @@ def test_all_nested(self, fig_test, fig_ref):
710702
@check_figures_equal(extensions=["png"])
711703
def test_nested(self, fig_test, fig_ref):
712704

713-
fig_ref.set_constrained_layout(True)
714-
fig_test.set_constrained_layout(True)
705+
fig_ref.set_layout_engine("constrained")
706+
fig_test.set_layout_engine("constrained")
715707

716708
x = [["A", "B"], ["C", "D"]]
717709

0 commit comments

Comments
 (0)