@@ -621,22 +621,26 @@ def add_axes(self, *args, **kwargs):
621621 args = (kwargs .pop ('rect' ), )
622622
623623 if isinstance (args [0 ], Axes ):
624- a = args [ 0 ]
624+ a , * extra_args = args
625625 key = a ._projection_init
626626 if a .get_figure () is not self :
627627 raise ValueError (
628628 "The Axes must have been created in the present figure" )
629629 else :
630- rect = args [ 0 ]
630+ rect , * extra_args = args
631631 if not np .isfinite (rect ).all ():
632- raise ValueError ('all entries in rect must be finite '
633- f'not { rect } ' )
634- projection_class , pkw = self ._process_projection_requirements (
635- * args , ** kwargs )
632+ raise ValueError (f'all entries in rect must be finite not { rect } ' )
633+ projection_class , pkw = self ._process_projection_requirements (** kwargs )
636634
637635 # create the new axes using the axes class given
638636 a = projection_class (self , rect , ** pkw )
639637 key = (projection_class , pkw )
638+
639+ if extra_args :
640+ _api .warn_deprecated (
641+ "3.8" ,
642+ name = "Passing more than one positional argument to Figure.add_axes" ,
643+ addendum = "Any additional positional arguments are now ignored." )
640644 return self ._add_axes_internal (a , key )
641645
642646 @_docstring .dedent_interpd
@@ -762,8 +766,7 @@ def add_subplot(self, *args, **kwargs):
762766 if (len (args ) == 1 and isinstance (args [0 ], Integral )
763767 and 100 <= args [0 ] <= 999 ):
764768 args = tuple (map (int , str (args [0 ])))
765- projection_class , pkw = self ._process_projection_requirements (
766- * args , ** kwargs )
769+ projection_class , pkw = self ._process_projection_requirements (** kwargs )
767770 ax = projection_class (self , * args , ** pkw )
768771 key = (projection_class , pkw )
769772 return self ._add_axes_internal (ax , key )
@@ -1662,9 +1665,8 @@ def _gci(self):
16621665 return im
16631666 return None
16641667
1665- def _process_projection_requirements (
1666- self , * args , axes_class = None , polar = False , projection = None ,
1667- ** kwargs ):
1668+ def _process_projection_requirements (self , * , axes_class = None , polar = False ,
1669+ projection = None , ** kwargs ):
16681670 """
16691671 Handle the args/kwargs to add_axes/add_subplot/gca, returning::
16701672
0 commit comments