8000 Deprecate cla() methods of Axis and Spines in favor of clear() · matplotlib/matplotlib@d3e4731 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3e4731

Browse files
committed
Deprecate cla() methods of Axis and Spines in favor of clear()
1 parent 6c3d8da commit d3e4731

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

doc/api/axis_api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Inheritance
4040
:template: autosummary.rst
4141
:nosignatures:
4242

43+
Axis.clear
4344
Axis.cla
4445
Axis.get_scale
4546

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``Axis.cla()`` and ``Spine.cla()``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
``Axis.cla()`` and ``Spine.cla()`` are deprecated in favor of the respective
5+
``clear()`` methods.

lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,11 +1100,11 @@ def cla(self):
11001100
xaxis_visible = self.xaxis.get_visible()
11011101
yaxis_visible = self.yaxis.get_visible()
11021102

1103-
self.xaxis.cla()
1104-
self.yaxis.cla()
1103+
self.xaxis.clear()
1104+
self.yaxis.clear()
11051105

11061106
for name, spine in self.spines.items():
1107-
spine.cla()
1107+
spine.clear()
11081108

11091109
self.ignore_existing_data_limits = True
11101110
self.callbacks = cbook.CallbackRegistry()

lib/matplotlib/axis.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ def __init__(self, axes, pickradius=15):
705705
self._major_tick_kw = dict()
706706
self._minor_tick_kw = dict()
707707

708-
self.cla()
708+
self.clear()
709709
self._set_scale('linear')
710710

711711
# During initialization, Axis objects often create ticks that are later
@@ -768,8 +768,19 @@ def get_children(self):
768768
return [self.label, self.offsetText,
769769
*self.get_major_ticks(), *self.get_minor_ticks()]
770770

771-
def cla(self):
772-
"""Clear this axis."""
771+
def clear(self):
772+
"""
773+
Clear the axis.
774+
775+
This resets axis properties to their default values:
776+
777+
- the label
778+
- the scale
779+
- locators, formatters and ticks
780+
- major and minor grid
781+
- units
782+
- registered callbacks
783+
"""
773784

774785
self.label.set_text('') # self.set_label_text would change isDefault_
775786

@@ -793,6 +804,11 @@ def cla(self):
793804
self.set_units(None)
794805
self.stale = True
795806

807+
@cbook.deprecated("3.4", alternative="Axis.clear()")
808+
def cla(self):
809+
"""Clear this axis."""
810+
return self.clear()
811+
796812
def reset_ticks(self):
797813
"""
798814
Re-initialize the major and minor Tick lists.

lib/matplotlib/spines.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,18 @@ def register_axis(self, axis):
228228
"""
229229
self.axis = axis
230230
if self.axis is not None:
231-
self.axis.cla()
231+
self.axis.clear()
232232
self.stale = True
233233

234-
def cla(self):
234+
def clear(self):
235235
"""Clear the current spine."""
236236
self._position = None # clear position
237237
if self.axis is not None:
238-
self.axis.cla()
238+
self.axis.clear()
239+
240+
@cbook.deprecated("3.4", alternative="Spine.clear()")
241+
def cla(self):
242+
self.clear()
239243

240244
def _adjust_location(self):
241245
"""Automatically set spine bounds to the view interval."""

0 commit comments

Comments
 (0)
0