Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c5fc8e

Browse filesBrowse files
authored
Merge pull request matplotlib#22802 from lijake8/mnt-make-cla-an-alias-for-clear
MNT: make Axes.cla an alias for Axes.clear in all cases
2 parents bae5c10 + ec95f99 commit 2c5fc8e
Copy full SHA for 2c5fc8e

File tree

Expand file treeCollapse file tree

13 files changed

+59
-47
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+59
-47
lines changed
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Removal of deprecated methods in `matplotlib.projections.polar`
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The ``cla`` method in both ``ThetaAxis`` and ``RadialAxis`` has been removed
5+
after being deprecated in 3.4. Use ``clear`` instead.
6+
7+
Removal of deprecated methods in `matplotlib.spines`
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
The ``cla`` method in ``Spine`` is removed after being deprecated in 3.4.
10+
Use ``clear`` instead.

‎examples/misc/custom_projection.py

Copy file name to clipboardExpand all lines: examples/misc/custom_projection.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def _init_axis(self):
5252
# self.spines['geo'].register_axis(self.yaxis)
5353
self._update_transScale()
5454

55-
def cla(self):
56-
super().cla()
55+
def clear(self):
56+
# docstring inherited
57+
super().clear()
5758

5859
self.set_longitude_grid(30)
5960
self.set_latitude_grid(15)
@@ -424,7 +425,7 @@ def __init__(self, *args, **kwargs):
424425
self._longitude_cap = np.pi / 2.0
425426
super().__init__(*args, **kwargs)
426427
self.set_aspect(0.5, adjustable='box', anchor='C')
427-
self.cla()
428+
self.clear()
428429

429430
def _get_core_transform(self, resolution):
430431
return self.HammerTransform(resolution)

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def __init__(self, fig, rect,
641641
self.set_axisbelow(mpl.rcParams['axes.axisbelow'])
642642

643643
self._rasterization_zorder = None
644-
self.cla()
644+
self.clear()
645645

646646
# funcs used to format x and y - fall back on major formatters
647647
self.fmt_xdata = None
@@ -1193,7 +1193,7 @@ def sharey(self, other):
11931193
self.set_ylim(y0, y1, emit=False, auto=other.get_autoscaley_on())
11941194
self.yaxis._scale = other.yaxis._scale
11951195

1196-
def cla(self):
1196+
def clear(self):
11971197
"""Clear the Axes."""
11981198
# Note: this is called by Axes.__init__()
11991199

@@ -1487,9 +1487,9 @@ def texts(self):
14871487
return self.ArtistList(self, 'texts', 'add_artist',
14881488
valid_types=mtext.Text)
14891489

1490-
def clear(self):
1490+
def cla(self):
14911491
"""Clear the Axes."""
1492-
self.cla()
1492+
self.clear()
14931493

14941494
def get_facecolor(self):
14951495
"""Get the facecolor of the Axes."""

‎lib/matplotlib/figure.py

Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def clear(self, keep_observers=False):
931931
self.subfigs = []
932932

933933
for ax in tuple(self.axes): # Iterate over the copy.
934-
ax.cla()
934+
ax.clear()
935935
self.delaxes(ax) # Remove ax from self._axstack.
936936

937937
self.artists = []

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ def _init_axis(self):
3636
# self.spines['geo'].register_axis(self.yaxis)
3737
self._update_transScale()
3838

39-
def cla(self):
40-
super().cla()
39+
def clear(self):
40+
# docstring inherited
41+
super().clear()
4142

4243
self.set_longitude_grid(30)
4344
self.set_latitude_grid(15)
@@ -284,7 +285,7 @@ def __init__(self, *args, **kwargs):
284285
self._longitude_cap = np.pi / 2.0
285286
super().__init__(*args, **kwargs)
286287
self.set_aspect(0.5, adjustable='box', anchor='C')
287-
self.cla()
288+
self.clear()
288289

289290
def _get_core_transform(self, resolution):
290291
return self.AitoffTransform(resolution)
@@ -329,7 +330,7 @@ def __init__(self, *args, **kwargs):
329330
self._longitude_cap = np.pi / 2.0
330331
super().__init__(*args, **kwargs)
331332
self.set_aspect(0.5, adjustable='box', anchor='C')
332-
self.cla()
333+
self.clear()
333334

334335
def _get_core_transform(self, resolution):
335336
return self.HammerTransform(resolution)
@@ -399,7 +400,7 @@ def __init__(self, *args, **kwargs):
399400
self._longitude_cap = np.pi / 2.0
400401
super().__init__(*args, **kwargs)
401402
self.set_aspect(0.5, adjustable='box', anchor='C')
402-
self.cla()
403+
self.clear()
403404

404405
def _get_core_transform(self, resolution):
405406
return self.MollweideTransform(resolution)
@@ -484,10 +485,11 @@ def __init__(self, *args, center_longitude=0, center_latitude=0, **kwargs):
484485
self._center_latitude = center_latitude
485486
super().__init__(*args, **kwargs)
486487
self.set_aspect('equal', adjustable='box', anchor='C')
487-
self.cla()
488+
self.clear()
488489

489-
def cla(self):
490-
super().cla()
490+
def clear(self):
491+
# docstring inherited
492+
super().clear()
491493
self.yaxis.set_major_formatter(NullFormatter())
492494

493495
def _get_core_transform(self, resolution):

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+6-11Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,11 @@ def _wrap_locator_formatter(self):
367367
self.isDefault_majfmt = True
368368

369369
def clear(self):
370+
# docstring inherited
370371
super().clear()
371372
self.set_ticks_position('none')
372373
self._wrap_locator_formatter()
373374

374-
@_api.deprecated("3.4", alternative="ThetaAxis.clear()")
375-
def cla(self):
376-
self.clear()
377-
378375
def _set_scale(self, value, **kwargs):
379376
if value != 'linear':
380377
raise NotImplementedError(
@@ -659,14 +656,11 @@ def _wrap_locator_formatter(self):
659656
self.isDefault_majloc = True
660657

661658
def clear(self):
659+
# docstring inherited
662660
super().clear()
663661
self.set_ticks_position('none')
664662
self._wrap_locator_formatter()
665663

666-
@_api.deprecated("3.4", alternative="RadialAxis.clear()")
667-
def cla(self):
668-
self.clear()
669-
670664
def _set_scale(self, value, **kwargs):
671665
super()._set_scale(value, **kwargs)
672666
self._wrap_locator_formatter()
@@ -764,10 +758,11 @@ def __init__(self, *args,
764758
super().__init__(*args, **kwargs)
765759
self.use_sticky_edges = True
766760
self.set_aspect('equal', adjustable='box', anchor='C')
767-
self.cla()
761+
self.clear()
768762

769-
def cla(self):
770-
super().cla()
763+
def clear(self):
764+
# docstring inherited
765+
super().clear()
771766

772767
self.title.set_y(1.05)
773768

‎lib/matplotlib/spines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/spines.py
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@ def clear(self):
222222
if self.axis is not None:
223223
self.axis.clear()
224224

225-
@_api.deprecated("3.4", alternative="`.Spine.clear`")
226-
def cla(self):
227-
self.clear()
228-
229225
def _adjust_location(self):
230226
"""Automatically set spine bounds to the view interval."""
231227

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import matplotlib.colors as mcolors
2323
import matplotlib.dates as mdates
2424
from matplotlib.figure import Figure
25+
from matplotlib.axes import Axes
2526
import matplotlib.font_manager as mfont_manager
2627
import matplotlib.markers as mmarkers
2728
import matplotlib.patches as mpatches
@@ -468,6 +469,12 @@ def test_inverted_cla():
468469
plt.close(fig)
469470

470471

472+
def test_cla_not_redefined():
473+
for klass in Axes.__subclasses__():
474+
# check that cla does not get redefined in our Axes subclasses
475+
assert 'cla' not in klass.__dict__
476+
477+
471478
@check_figures_equal(extensions=["png"])
472479
def test_minorticks_on_rcParams_both(fig_test, fig_ref):
473480
with matplotlib.rc_context({"xtick.minor.visible": True,

‎lib/mpl_toolkits/axes_grid1/mpl_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/mpl_axes.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def _init_axis_artists(self):
5252
def axis(self):
5353
return self._axislines
5454

55-
def cla(self):
56-
super().cla()
55+
def clear(self):
56+
# docstring inherited
57+
super().clear()
5758
self._init_axis_artists()
5859

5960

‎lib/mpl_toolkits/axes_grid1/parasite_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axes_grid1/parasite_axes.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def __init__(self, parent_axes, aux_transform=None,
1717
kwargs["frameon"] = False
1818
super().__init__(parent_axes.figure, parent_axes._position, **kwargs)
1919

20-
def cla(self):
21-
super().cla()
20+
def clear(self):
21+
super().clear()
2222
martist.setp(self.get_children(), visible=False)
2323
self._get_lines = self._parent_axes._get_lines
2424

@@ -138,10 +138,10 @@ def draw(self, renderer):
138138
super().draw(renderer)
139139
self._children = self._children[:orig_children_len]
140140

141-
def cla(self):
141+
def clear(self):
142142
for ax in self.parasites:
143-
ax.cla()
144-
super().cla()
143+
ax.clear()
144+
super().clear()
145145

146146
def pick(self, mouseevent):
147147
super().pick(mouseevent)

‎lib/mpl_toolkits/axisartist/axislines.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axislines.py
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,13 @@ def _init_gridlines(self, grid_helper=None):
499499
# It is done inside the cla.
500500
self.gridlines = self.new_gridlines(grid_helper)
501501

502-
def cla(self):
503-
# gridlines need to b created before cla() since cla calls grid()
502+
def clear(self):
503+
# docstring inherited
504+
# gridlines need to be created before clear() since clear calls grid()
504505
self._init_gridlines()
505-
super().cla()
506+
super().clear()
506507

507-
# the clip_path should be set after Axes.cla() since that's
508+
# the clip_path should be set after Axes.clear() since that's
508509
# when a patch is created.
509510
self.gridlines.set_clip_path(self.axes.patch)
510511

‎lib/mpl_toolkits/axisartist/floating_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/floating_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def _gen_axes_patch(self):
329329
patch.get_path()._interpolation_steps = 100
330330
return patch
331331

332-
def cla(self):
333-
super().cla()
332+
def clear(self):
333+
super().clear()
334334
self.patch.set_transform(
335335
self.get_grid_helper().grid_finder.get_transform()
336336
+ self.transData)

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,9 @@ def can_pan(self):
932932
"""
933933
return False
934934

935-
def cla(self):
935+
def clear(self):
936936
# docstring inherited.
937-
938-
super().cla()
937+
super().clear()
939938
self.zaxis.clear()
940939

941940
if self._sharez is not None:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.