Revision: 8579
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8579&view=rev
Author:   efiring
Date:     2010-07-26 19:14:16 +0000 (Mon, 26 Jul 2010)

Log Message:
-----------
[3032390] subplot: more robust argument handling, consistent with 0.99.3

Modified Paths:
--------------
    branches/v1_0_maint/lib/matplotlib/axes.py
    branches/v1_0_maint/lib/matplotlib/gridspec.py

Modified: branches/v1_0_maint/lib/matplotlib/axes.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/axes.py  2010-07-26 18:20:35 UTC (rev 
8578)
+++ branches/v1_0_maint/lib/matplotlib/axes.py  2010-07-26 19:14:16 UTC (rev 
8579)
@@ -8295,6 +8295,7 @@
         being created.  *plotNum* starts at 1 in the upper left
         corner and increases to the right.
 
+
         If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
         decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
         """
@@ -8304,25 +8305,28 @@
         if len(args) == 1:
             if isinstance(args[0], SubplotSpec):
                 self._subplotspec = args[0]
-
             else:
-                s = str(args[0])
-                if len(s) != 3:
-                    raise ValueError('Argument to subplot must be a 3 digits 
long')
-                rows, cols, num = map(int, s)
+                try:
+                    s = str(int(args[0]))
+                    rows, cols, num = map(int, s)
+                except ValueError:
+                    raise ValueError(
+                         'Single argument to subplot must be a 3-digit 
integer')
                 self._subplotspec = GridSpec(rows, cols)[num-1]
                 # num - 1 for converting from MATLAB to python indexing
         elif len(args)==3:
             rows, cols, num = args
+            rows = int(rows)
+            cols = int(cols)
             if isinstance(num, tuple) and len(num) == 2:
+                num = [int(n) for n in num]
                 self._subplotspec = GridSpec(rows, cols)[num[0]-1:num[1]]
             else:
-                self._subplotspec = GridSpec(rows, cols)[num-1]
+                self._subplotspec = GridSpec(rows, cols)[int(num)-1]
                 # num - 1 for converting from MATLAB to python indexing
         else:
-            raise ValueError(  'Illegal argument to subplot')
+            raise ValueError('Illegal argument(s) to subplot: %s' % (args,))
 
-
         self.update_params()
 
         # _axes_class is set in the subplot_class_factory

Modified: branches/v1_0_maint/lib/matplotlib/gridspec.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/gridspec.py      2010-07-26 18:20:35 UTC 
(rev 8578)
+++ branches/v1_0_maint/lib/matplotlib/gridspec.py      2010-07-26 19:14:16 UTC 
(rev 8579)
@@ -70,7 +70,7 @@
     def get_height_ratios(self):
         return self._row_height_ratios
 
-    
+
     def get_grid_positions(self, fig):
         """
         return lists of bottom and top position of rows, left and
@@ -116,9 +116,9 @@
 
         sepWidths = [0] + ([sepW] * (ncols-1))
         cellWs = np.add.accumulate(np.ravel(zip(sepWidths, cellWidths)))
-            
 
 
+
         figTops = [top - cellHs[2*rowNum] for rowNum in range(nrows)]
         figBottoms = [top - cellHs[2*rowNum+1] for rowNum in range(nrows)]
         figLefts = [left + cellWs[2*colNum] for colNum in range(ncols)]
@@ -126,8 +126,8 @@
 
 
         return figBottoms, figTops, figLefts, figRights
-        
 
+
     def __getitem__(self, key):
         """
         create and return a SuplotSpec instance.
@@ -287,7 +287,7 @@
 
     def get_subplot_params(self, fig=None):
         """
-        return a dictionary of subplot layout parameters. 
+        return a dictionary of subplot layout parameters.
         """
 
         if fig is None:
@@ -324,7 +324,7 @@
     """
     specifies the location of the subplot in the given *GridSpec*.
     """
-    
+
     def __init__(self, gridspec, num1, num2=None):
         """
         The subplot will occupy the num1-th cell of the given


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to