From 85438a03b89f7e71b6802a0be2eacc165fc317e5 Mon Sep 17 00:00:00 2001 From: pwuertz Date: Tue, 28 Aug 2012 22:06:40 +0200 Subject: [PATCH] tight_layout: fix regression for figures with non SubplotBase Axes --- lib/matplotlib/figure.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 2dafa2c5827b..6dc6e0361529 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1424,16 +1424,15 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None, rect=Non from tight_layout import get_renderer, get_tight_layout_figure - no_go = [ax for ax in self.axes if not isinstance(ax, SubplotBase)] - if no_go: - warnings.Warn("Cannot use tight_layout;" - " all Axes must descend from SubplotBase") - return + subplot_axes = [ax for ax in self.axes if isinstance(ax, SubplotBase)] + if len(subplot_axes) < len(self.axes): + warnings.warn("tight_layout can only process Axes that descend " + "from SubplotBase; results might be incorrect.") if renderer is None: renderer = get_renderer(self) - kwargs = get_tight_layout_figure(self, self.axes, renderer, + kwargs = get_tight_layout_figure(self, subplot_axes, renderer, pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)