Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: turn off layout engine tightbbox #24167

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ def print_figure(
_bbox_inches_restore = None

# we have already done layout above, so turn it off:
stack.enter_context(self.figure._cm_set(layout_engine=None))
stack.enter_context(self.figure._cm_set(layout_engine='none'))
try:
# _get_renderer may change the figure dpi (as vector formats
# force the figure dpi to 72), so we need to set it again here.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions lib/matplotlib/tests/test_bbox_tight.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,13 @@ def test_noop_tight_bbox():
assert (im[:, :, 3] == 255).all()
assert not (im[:, :, :3] == 255).all()
assert im.shape == (7, 10, 4)


@image_comparison(['bbox_inches_fixed_aspect'], extensions=['png'],
remove_text=True, savefig_kwarg={'bbox_inches': 'tight'})
def test_bbox_inches_fixed_aspect():
with plt.rc_context({'figure.constrained_layout.use': True}):
fig, ax = plt.subplots()
ax.plot([0, 1])
ax.set_xlim(0, 1)
ax.set_aspect('equal')