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

Skip to content

Commit 5698d3f

Browse files
authored
Merge pull request #11777 from fredrik-1/warning_savefig
Avoid incorrect warning in savefig
2 parents 9857e7c + a16c065 commit 5698d3f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/tight_bbox.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ def adjust_bbox(fig, bbox_inches, fixed_dpi=None):
1818

1919
origBbox = fig.bbox
2020
origBboxInches = fig.bbox_inches
21+
orig_tight_layout = fig.get_tight_layout()
2122
_boxout = fig.transFigure._boxout
2223

24+
fig.set_tight_layout(False)
25+
2326
asp_list = []
2427
locator_list = []
2528
for ax in fig.axes:
@@ -33,13 +36,13 @@ def _l(a, r, pos=pos):
3336
ax.set_aspect("auto")
3437

3538
def restore_bbox():
36-
3739
for ax, asp, loc in zip(fig.axes, asp_list, locator_list):
3840
ax.set_aspect(asp)
3941
ax.set_axes_locator(loc)
4042

4143
fig.bbox = origBbox
4244
fig.bbox_inches = origBboxInches
45+
fig.set_tight_layout(orig_tight_layout)
4346
fig.transFigure._boxout = _boxout
4447
fig.transFigure.invalidate()
4548
fig.patch.set_bounds(0, 0, 1, 1)

0 commit comments

Comments
 (0)