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

Appearance settings

Commit 235b01f

Browse filesBrowse files
authored
Merge pull request #24971 from rcomer/adjust_bbox-layout-engine
FIX: adjust_bbox should not modify layout engine
2 parents 90fe9e0 + 3c28528 commit 235b01f
Copy full SHA for 235b01f

File tree

Expand file treeCollapse file tree

2 files changed

+7
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-3
lines changed

‎lib/matplotlib/_tight_bbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_tight_bbox.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def adjust_bbox(fig, bbox_inches, fixed_dpi=None):
1717
"""
1818
origBbox = fig.bbox
1919
origBboxInches = fig.bbox_inches
20-
orig_layout = fig.get_layout_engine()
21-
fig.set_layout_engine(None)
2220
_boxout = fig.transFigure._boxout
2321

2422
old_aspect = []
@@ -46,7 +44,6 @@ def restore_bbox():
4644

4745
fig.bbox = origBbox
4846
fig.bbox_inches = origBboxInches
49-
fig.set_layout_engine(orig_layout)
5047
fig.transFigure._boxout = _boxout
5148
fig.transFigure.invalidate()
5249
fig.patch.set_bounds(0, 0, 1, 1)

‎lib/matplotlib/tests/test_figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_figure.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,13 @@ def test_savefig_pixel_ratio(backend):
532532
assert ratio1 == ratio2
533533

534534

535+
def test_savefig_preserve_layout_engine(tmp_path):
536+
fig = plt.figure(layout='compressed')
537+
fig.savefig(tmp_path / 'foo.png', bbox_inches='tight')
538+
539+
assert fig.get_layout_engine()._compress
540+
541+
535542
def test_figure_repr():
536543
fig = plt.figure(figsize=(10, 20), dpi=10)
537544
assert repr(fig) == "<Figure size 100x200 with 0 Axes>"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.