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

Fix toggling layout engines#24924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromQuLogic:layout-toggles
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletionslib/matplotlib/figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2760,9 +2760,9 @@ def set_tight_layout(self, tight):
"""
if tight is None:
tight = mpl.rcParams['figure.autolayout']
_tight = 'tight' if bool(tight) else 'none'
_tight_parameters = tight if isinstance(tight, dict) else {}
if bool(tight):
self.set_layout_engine(TightLayoutEngine(**_tight_parameters))
self.set_layout_engine(_tight, **_tight_parameters)
self.stale = True

def get_constrained_layout(self):
Expand DownExpand Up@@ -2797,10 +2797,9 @@ def set_constrained_layout(self, constrained):
"""
if constrained is None:
constrained = mpl.rcParams['figure.constrained_layout.use']
_constrained = bool(constrained)
_constrained ='constrained' ifbool(constrained) else 'none'
_parameters = constrained if isinstance(constrained, dict) else {}
if _constrained:
self.set_layout_engine(ConstrainedLayoutEngine(**_parameters))
self.set_layout_engine(_constrained, **_parameters)
self.stale = True

@_api.deprecated(
Expand Down
11 changes: 11 additions & 0 deletionslib/matplotlib/tests/test_constrainedlayout.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -667,3 +667,14 @@ def test_compressed1():
def test_set_constrained_layout(arg, state):
fig, ax = plt.subplots(constrained_layout=arg)
assert fig.get_constrained_layout() is state


def test_constrained_toggle():
fig, ax = plt.subplots()
with pytest.warns(PendingDeprecationWarning):
fig.set_constrained_layout(True)
assert fig.get_constrained_layout()
fig.set_constrained_layout(False)
assert not fig.get_constrained_layout()
fig.set_constrained_layout(True)
assert fig.get_constrained_layout()
11 changes: 11 additions & 0 deletionslib/matplotlib/tests/test_tightlayout.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -380,3 +380,14 @@ def test_tight_pads():
def test_tight_kwargs():
fig, ax = plt.subplots(tight_layout={'pad': 0.15})
fig.draw_without_rendering()


def test_tight_toggle():
fig, ax = plt.subplots()
with pytest.warns(PendingDeprecationWarning):
fig.set_tight_layout(True)
assert fig.get_tight_layout()
fig.set_tight_layout(False)
assert not fig.get_tight_layout()
fig.set_tight_layout(True)
assert fig.get_tight_layout()

[8]ページ先頭

©2009-2025 Movatter.jp