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

Commit5a69602

Browse files
committed
FIX
1 parent8aac613 commit5a69602

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed
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
ifuse_gridspec:
1150-
if (self.layout_engineisnotNoneand
1151-
notself.layout_engine.colorbar_gridspec):
1150+
if (self.get_layout_engine()isnotNoneand
1151+
notself.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
ifcaxisNone:
@@ -2064,6 +2064,9 @@ def get_constrained_layout_pads(self, relative=False):
20642064
"""
20652065
returnself._parent.get_constrained_layout_pads(relative=relative)
20662066

2067+
defget_layout_engine(self):
2068+
returnself._parent.get_layout_engine()
2069+
20672070
@property
20682071
defaxes(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
assertrepr(fig)=="<Figure size 100x200 with 0 Axes>"
506506

507507

508-
deftest_warn_cl_plus_tl():
509-
fig,ax=plt.subplots(constrained_layout=True)
510-
withpytest.warns(UserWarning):
511-
# this should warn,
512-
fig.subplots_adjust(top=0.8)
513-
assertnot(fig.get_constrained_layout())
514-
515-
516508
@check_figures_equal(extensions=["png","pdf"])
517509
deftest_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
foraxingrid_axes.values():
@@ -710,8 +702,8 @@ def test_all_nested(self, fig_test, fig_ref):
710702
@check_figures_equal(extensions=["png"])
711703
deftest_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)

[8]ページ先頭

©2009-2025 Movatter.jp