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

BUG: Warn when an existing layout manager changes to tight layout#24528

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
dstansby merged 1 commit intomatplotlib:mainfromj1642:warn-if-tight-layout
Dec 7, 2022
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
4 changes: 4 additions & 0 deletionslib/matplotlib/figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3430,8 +3430,12 @@ def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None):
engine = TightLayoutEngine(pad=pad, h_pad=h_pad, w_pad=w_pad,
rect=rect)
try:
previous_engine = self.get_layout_engine()
self.set_layout_engine(engine)
engine.execute(self)
if not isinstance(previous_engine, TightLayoutEngine) \
and previous_engine is not None:
_api.warn_external('The figure layout has changed to tight')
finally:
self.set_layout_engine(None)

Expand Down
11 changes: 11 additions & 0 deletionslib/matplotlib/tests/test_figure.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -598,6 +598,17 @@ def test_invalid_layouts():
fig.set_layout_engine("constrained")


@pytest.mark.parametrize('layout', ['constrained', 'compressed'])
def test_layout_change_warning(layout):
"""
Raise a warning when a previously assigned layout changes to tight using
plt.tight_layout().
"""
fig, ax = plt.subplots(layout=layout)
with pytest.warns(UserWarning, match='The figure layout has changed to'):
plt.tight_layout()


@check_figures_equal(extensions=["png", "pdf"])
def test_add_artist(fig_test, fig_ref):
fig_test.dpi = 100
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp