@@ -8295,6 +8295,7 @@ def __init__(self, fig, *args, **kwargs):
8295
8295
being created. *plotNum* starts at 1 in the upper left
8296
8296
corner and increases to the right.
8297
8297
8298
+
8298
8299
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
8299
8300
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
8300
8301
"""
@@ -8304,24 +8305,27 @@ def __init__(self, fig, *args, **kwargs):
8304
8305
if len (args ) == 1 :
8305
8306
if isinstance (args [0 ], SubplotSpec ):
8306
8307
self ._subplotspec = args [0 ]
8307
-
8308
8308
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' )
8313
8315
self ._subplotspec = GridSpec (rows , cols )[num - 1 ]
8314
8316
# num - 1 for converting from MATLAB to python indexing
8315
8317
elif len (args )== 3 :
8316
8318
rows , cols , num = args
8319
+ rows = int (rows )
8320
+ cols = int (cols )
8317
8321
if isinstance (num , tuple ) and len (num ) == 2 :
8322
+ num = [int (n ) for n in num ]
8318
8323
self ._subplotspec = GridSpec (rows , cols )[num [0 ]- 1 :num [1 ]]
8319
8324
else :
8320
- self ._subplotspec = GridSpec (rows , cols )[num - 1 ]
8325
+ self ._subplotspec = GridSpec (rows , cols )[int ( num ) - 1 ]
8321
8326
# num - 1 for converting from MATLAB to python indexing
8322
8327
else :
8323
- raise ValueError ( 'Illegal argument to subplot' )
8324
-
8328
+ raise ValueError ('Illegal argument(s) to subplot: %s' % (args ,))
8325
8329
8326
8330
self .update_params ()
8327
8331
0 commit comments