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

Skip to content

Commit 0c7cdaa

Browse files
committed
Merge pull request #1163 from pwuertz/fix-tightlayout-bug
tight_layout: fix regression for figures with non SubplotBase Axes
2 parents cfc1d81 + 85438a0 commit 0c7cdaa

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/matplotlib/figure.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,16 +1424,15 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=Non
14241424

14251425
from tight_layout import get_renderer, get_tight_layout_figure
14261426

1427-
no_go = [ax for ax in self.axes if not isinstance(ax, SubplotBase)]
1428-
if no_go:
1429-
warnings.Warn("Cannot use tight_layout;"
1430-
" all Axes must descend from SubplotBase")
1431-
return
1427+
subplot_axes = [ax for ax in self.axes if isinstance(ax, SubplotBase)]
1428+
if len(subplot_axes) < len(self.axes):
1429+
warnings.warn("tight_layout can only process Axes that descend "
1430+
"from SubplotBase; results might be incorrect.")
14321431

14331432
if renderer is None:
14341433
renderer = get_renderer(self)
14351434

1436-
kwargs = get_tight_layout_figure(self, self.axes, renderer,
1435+
kwargs = get_tight_layout_figure(self, subplot_axes, renderer,
14371436
pad=pad, h_pad=h_pad, w_pad=w_pad,
14381437
rect=rect)
14391438

0 commit comments

Comments
 (0)