@@ -47,10 +47,10 @@ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None):
4747 """
4848 if not isinstance (nrows , Integral ) or nrows <= 0 :
4949 raise ValueError (
50- f"Number of rows must be a positive integer, not { nrows } " )
50+ f"Number of rows must be a positive integer, not { nrows !r } " )
5151 if not isinstance (ncols , Integral ) or ncols <= 0 :
5252 raise ValueError (
53- f"Number of columns must be a positive integer, not { ncols } " )
53+ f"Number of columns must be a positive integer, not { ncols !r } " )
5454 self ._nrows , self ._ncols = nrows , ncols
5555 self .set_height_ratios (height_ratios )
5656 self .set_width_ratios (width_ratios )
@@ -604,51 +604,40 @@ def _from_subplot_args(figure, args):
604604 - a `.SubplotSpec` -- returned as is;
605605 - one or three numbers -- a MATLAB-style subplot specifier.
606606 """
607- message = ("Passing non-integers as three-element position "
608- "specification is deprecated since %(since)s and will be "
609- "removed %(removal)s." )
610607 if len (args ) == 1 :
611608 arg , = args
612609 if isinstance (arg , SubplotSpec ):
613610 return arg
614- else :
615- if not isinstance (arg , Integral ):
616- _api .warn_deprecated ("3.3" , message = message )
617- arg = str (arg )
618- try :
619- rows , cols , num = map (int , str (arg ))
620- except ValueError :
621- raise ValueError (
622- f"Single argument to subplot must be a three-digit "
623- f"integer, not { arg } " ) from None
624- i = j = num
611+ elif not isinstance (arg , Integral ):
612+ raise ValueError (
613+ f"Single argument to subplot must be a three-digit "
614+ f"integer, not { arg !r} " )
615+ try :
616+ rows , cols , num = map (int , str (arg ))
617+ except ValueError :
618+ raise ValueError (
619+ f"Single argument to subplot must be a three-digit "
620+ f"integer, not { arg !r} " ) from None
625621 elif len (args ) == 3 :
626622 rows , cols , num = args
627- if not (isinstance (rows , Integral ) and isinstance (cols , Integral )):
628- _api .warn_deprecated ("3.3" , message = message )
629- rows , cols = map (int , [rows , cols ])
630- gs = GridSpec (rows , cols , figure = figure )
631- if isinstance (num , tuple ) and len (num ) == 2 :
632- if not all (isinstance (n , Integral ) for n in num ):
633- _api .warn_deprecated ("3.3" , message = message )
634- i , j = map (int , num )
635- else :
636- i , j = num
637- else :
638- if not isinstance (num , Integral ):
639- _api .warn_deprecated ("3.3" , message = message )
640- num = int (num )
641- if num < 1 or num > rows * cols :
642- raise ValueError (
643- f"num must be 1 <= num <= { rows * cols } , not { num } " )
644- i = j = num
645623 else :
646624 raise TypeError (f"subplot() takes 1 or 3 positional arguments but "
647625 f"{ len (args )} were given" )
648626
649627 gs = GridSpec ._check_gridspec_exists (figure , rows , cols )
650628 if gs is None :
651629 gs = GridSpec (rows , cols , figure = figure )
630+ if isinstance (num , tuple ) and len (num ) == 2 :
631+ if not all (isinstance (n , Integral ) for n in num ):
632+ raise ValueError (
633+ f"Subplot specifier tuple must contain integers, not { num } "
634+ )
635+ i , j = num
636+ else :
637+ if not isinstance (num , Integral ) or num < 1 or num > rows * cols :
638+ raise ValueError (
639+ f"num must be 1 <= num <= { rows * cols } , not { num !r} " )
640+ i = j = num
652641 return gs [i - 1 :j ]
653642
654643 # num2 is a property only to handle the case where it is None and someone
@@ -679,18 +668,6 @@ def get_geometry(self):
679668 rows , cols = self .get_gridspec ().get_geometry ()
680669 return rows , cols , self .num1 , self .num2
681670
682- @_api .deprecated ("3.3" , alternative = "rowspan, colspan" )
683- def get_rows_columns (self ):
684- """
685- Return the subplot row and column numbers as a tuple
686- ``(n_rows, n_cols, row_start, row_stop, col_start, col_stop)``.
687- """
688- gridspec = self .get_gridspec ()
689- nrows , ncols = gridspec .get_geometry ()
690- row_start , col_start = divmod (self .num1 , ncols )
691- row_stop , col_stop = divmod (self .num2 , ncols )
692- return nrows , ncols , row_start , row_stop , col_start , col_stop
693-
694671 @property
695672 def rowspan (self ):
696673 """The rows spanned by this subplot, as a `range` object."""
0 commit comments