@@ -8295,6 +8295,7 @@ def __init__(self, fig, *args, **kwargs):
82958295 being created. *plotNum* starts at 1 in the upper left
82968296 corner and increases to the right.
82978297
8298+
82988299 If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
82998300 decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
83008301 """
@@ -8304,24 +8305,27 @@ def __init__(self, fig, *args, **kwargs):
83048305 if len (args ) == 1 :
83058306 if isinstance (args [0 ], SubplotSpec ):
83068307 self ._subplotspec = args [0 ]
8307-
83088308 else :
8309- s = str (args [0 ])
8310- if len (s ) != 3 :
8311- raise ValueError ('Argument to subplot must be a 3 digits long' )
8312- rows , cols , num = map (int , s )
8309+ try :
8310+ s = str (int (args [0 ]))
8311+ rows , cols , num = map (int , s )
8312+ except ValueError :
8313+ raise ValueError (
8314+ 'Single argument to subplot must be a 3-digit integer' )
83138315 self ._subplotspec = GridSpec (rows , cols )[num - 1 ]
83148316 # num - 1 for converting from MATLAB to python indexing
83158317 elif len (args )== 3 :
83168318 rows , cols , num = args
8319+ rows = int (rows )
8320+ cols = int (cols )
83178321 if isinstance (num , tuple ) and len (num ) == 2 :
8322+ num = [int (n ) for n in num ]
83188323 self ._subplotspec = GridSpec (rows , cols )[num [0 ]- 1 :num [1 ]]
83198324 else :
8320- self ._subplotspec = GridSpec (rows , cols )[num - 1 ]
8325+ self ._subplotspec = GridSpec (rows , cols )[int ( num ) - 1 ]
83218326 # num - 1 for converting from MATLAB to python indexing
83228327 else :
8323- raise ValueError ( 'Illegal argument to subplot' )
8324-
8328+ raise ValueError ('Illegal argument(s) to subplot: %s' % (args ,))
83258329
83268330 self .update_params ()
83278331
0 commit comments