Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tight_layout: fix regression for figures with non SubplotBase Axes

  • Loading branch information...
commit 85438a03b89f7e71b6802a0be2eacc165fc317e5 1 parent cfc1d81
authored August 28, 2012

Showing 1 changed file with 5 additions and 6 deletions. Show diff stats Hide diff stats

  1. 11  lib/matplotlib/figure.py
11  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
1424 1424
 
1425 1425
         from tight_layout import get_renderer, get_tight_layout_figure
1426 1426
 
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.")
1432 1431
 
1433 1432
         if renderer is None:
1434 1433
             renderer = get_renderer(self)
1435 1434
 
1436  
-        kwargs = get_tight_layout_figure(self, self.axes, renderer,
  1435
+        kwargs = get_tight_layout_figure(self, subplot_axes, renderer,
1437 1436
                                          pad=pad, h_pad=h_pad, w_pad=w_pad,
1438 1437
                                          rect=rect)
1439 1438
 

0 notes on commit 85438a0

Please sign in to comment.
Something went wrong with that request. Please try again.