Skip to content

Commit 22bbbae

Browse files
authored
Merge pull request #13603 from jklymak/fix-bail-tight-layout
FIX: continue to bail tight layout if rect supplied
2 parents 1752c56 + f9d8cd7 commit 22bbbae

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/matplotlib/tests/test_tightlayout.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,5 @@ def test_collapsed():
323323
plt.tight_layout()
324324
p2 = ax.get_position()
325325
assert p1.width == p2.width
326+
# test that passing a rect doesn't crash...
327+
plt.tight_layout(rect=[0, 0, 0.8, 0.8])

lib/matplotlib/tight_layout.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
361361
ax_bbox_list=ax_bbox_list,
362362
pad=pad, h_pad=h_pad, w_pad=w_pad)
363363

364-
if rect is not None:
364+
# kwargs can be none if tight_layout fails...
365+
if rect is not None and kwargs is not None:
365366
# if rect is given, the whole subplots area (including
366367
# labels) will fit into the rect instead of the
367368
# figure. Note that the rect argument of

0 commit comments

Comments
 (0)