@@ -559,6 +559,8 @@ class _AxesBase(martist.Artist):
559559 _shared_axes = {name : cbook .Grouper () for name in _axis_names }
560560 _twinned_axes = cbook .Grouper ()
561561
562+ _subclass_uses_cla = False
563+
562564 @property
563565 def _axis_map (self ):
564566 """A mapping of axis names, e.g. 'x', to `Axis` instances."""
@@ -699,6 +701,19 @@ def __init__(self, fig, rect,
699701 rcParams ['ytick.major.right' ]),
700702 which = 'major' )
701703
704+ def __init_subclass__ (cls , ** kwargs ):
705+ parent_uses_cla = super (cls , cls )._subclass_uses_cla
706+ if 'cla' in cls .__dict__ :
707+ _api .warn_deprecated (
708+ '3.6' ,
709+ pending = True ,
710+ message = f'Overriding `Axes.cla` in { cls .__qualname__ } is '
711+ 'pending deprecation in %(since)s and will be fully '
712+ 'deprecated for `Axes.clear` in the future. Please report '
713+ f'this to the { cls .__module__ !r} author.' )
714+ cls ._subclass_uses_cla = 'cla' in cls .__dict__ or parent_uses_cla
715+ super ().__init_subclass__ (** kwargs )
716+
702717 def __getstate__ (self ):
703718 state = super ().__getstate__ ()
704719 # Prune the sharing & twinning info to only contain the current group.
@@ -1199,7 +1214,7 @@ def sharey(self, other):
11991214 self .set_ylim (y0 , y1 , emit = False , auto = other .get_autoscaley_on ())
12001215 self .yaxis ._scale = other .yaxis ._scale
12011216
1202- def clear (self ):
1217+ def _clear (self ):
12031218 """Clear the Axes."""
12041219 # Note: this is called by Axes.__init__()
12051220
@@ -1318,6 +1333,24 @@ def clear(self):
13181333
13191334 self .stale = True
13201335
1336+ def clear (self ):
1337+ """Clear the Axes."""
1338+ # Act as an alias, or as the superclass implementation depending on the
1339+ # subclass implementation.
1340+ if self ._subclass_uses_cla :
1341+ self .cla ()
1342+ else :
1343+ self ._clear ()
1344+
1345+ def cla (self ):
1346+ """Clear the Axes."""
1347+ # Act as an alias, or as the superclass implementation depending on the
1348+ # subclass implementation.
1349+ if self ._subclass_uses_cla :
1350+ self ._clear ()
1351+ else :
1352+ self .clear ()
1353+
13211354 class ArtistList (MutableSequence ):
13221355 """
13231356 A sublist of Axes children based on their type.
@@ -1481,10 +1514,6 @@ def texts(self):
14811514 return self .ArtistList (self , 'texts' , 'add_artist' ,
14821515 valid_types = mtext .Text )
14831516
1484- def cla (self ):
1485- """Clear the Axes."""
1486- self .clear ()
1487-
14881517 def get_facecolor (self ):
14891518 """Get the facecolor of the Axes."""
14901519 return self .patch .get_facecolor ()
0 commit comments