Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80c6512

Browse files
authored
Merge pull request #20331 from QuLogic/remove-axis-deprecations
Remove Axis, Tick, and Axes deprecations from 3.3
2 parents d7d50d9 + d6ffe48 commit 80c6512

File tree

10 files changed

+88
-188
lines changed

10 files changed

+88
-188
lines changed

doc/api/axes_api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ Axis limits and direction
295295
Axes.get_ylim
296296

297297
Axes.update_datalim
298-
Axes.update_datalim_bounds
299298

300299
Axes.set_xbound
301300
Axes.get_xbound
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
``Axes.pie`` *radius*, *startangle*, and *normalize* parameters
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Passing ``None`` as either the *radius* or *startangle* arguments of an
4+
`.Axes.pie` is no longer accepted; use the explicit defaults of 1 and 0,
5+
respectively, instead.
6+
7+
Passing ``None`` as the *normalize* argument of `.Axes.pie` (the former
8+
default) is no longer accepted, and the pie will always be normalized by
9+
default. If you wish to plot an incomplete pie, explicitly pass
10+
``normalize=False``.
11+
12+
Signatures of `.Artist.draw` and `.Axes.draw`
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
The *inframe* parameter to `.Axes.draw` has been removed. Use
15+
`.Axes.redraw_in_frame` instead.
16+
17+
Omitting the *renderer* parameter to `.Axes.draw` is no longer supported.
18+
Use ``axes.draw_artist(axes)`` instead.
19+
20+
These changes make the signature of the ``draw`` (``artist.draw(renderer)``)
21+
method consistent across all artists; thus, additional parameters to
22+
`.Artist.draw` have also been removed.
23+
24+
``Axes.update_datalim_bounds``
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
This method has been removed. Use
27+
``ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))`` instead.
28+
29+
``{,Symmetrical}LogScale.{,Inverted}LogTransform``
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
``LogScale.LogTransform``, ``LogScale.InvertedLogTransform``,
32+
``SymmetricalScale.SymmetricalTransform`` and
33+
``SymmetricalScale.InvertedSymmetricalTransform`` have been removed. Directly
34+
access the transform classes from the `matplotlib.scale` module.
35+
36+
log/symlog scale base, ticks, and nonpos specification
37+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38+
`~.Axes.semilogx`, `~.Axes.semilogy`, `~.Axes.loglog`, `.LogScale`, and
39+
`.SymmetricalLogScale` used to take keyword arguments that depends on the axis
40+
orientation ("basex" vs "basey", "subsx" vs "subsy", "nonposx" vs "nonposy");
41+
these parameter names have been removed in favor of "base", "subs",
42+
"nonpositive". This removal also affects e.g. ``ax.set_yscale("log",
43+
basey=...)`` which must now be spelled ``ax.set_yscale("log", base=...)``.
44+
45+
The change from "nonpos" to "nonpositive" also affects `~.scale.LogTransform`,
46+
`~.scale.InvertedLogTransform`, `~.scale.SymmetricalLogTransform`, etc.
47+
48+
To use *different* bases for the x-axis and y-axis of a `~.Axes.loglog` plot,
49+
use e.g. ``ax.set_xscale("log", base=10); ax.set_yscale("log", base=2)``.
50+
51+
Implicit initialization of ``Tick`` attributes
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
The `.Tick` constructor no longer initializes the attributes ``tick1line``,
55+
``tick2line``, ``gridline``, ``label1``, and ``label2`` via ``_get_tick1line``,
56+
``_get_tick2line``, ``_get_gridline``, ``_get_text1``, and ``_get_text2``.
57+
Please directly set the attribute in the subclass' ``__init__`` instead.
58+
59+
Unused parameters
60+
~~~~~~~~~~~~~~~~~
61+
The following parameters do not have any effect and have been removed:
62+
63+
- parameter *label* of `.Tick`

lib/matplotlib/artist.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ def allow_rasterization(draw):
2727
renderer.
2828
"""
2929

30-
# Axes has a second (deprecated) argument inframe for its draw method.
31-
# args and kwargs are deprecated, but we don't wrap this in
32-
# _api.delete_parameter for performance; the relevant deprecation
33-
# warning will be emitted by the inner draw() call.
3430
@wraps(draw)
35-
def draw_wrapper(artist, renderer, *args, **kwargs):
31+
def draw_wrapper(artist, renderer):
3632
try:
3733
if artist.get_rasterized():
3834
if renderer._raster_depth == 0 and not renderer._rasterizing:
@@ -49,7 +45,7 @@ def draw_wrapper(artist, renderer, *args, **kwargs):
4945
if artist.get_agg_filter() is not None:
5046
renderer.start_filter()
5147

52-
return draw(artist, renderer, *args, **kwargs)
48+
return draw(artist, renderer)
5349
finally:
5450
if artist.get_agg_filter() is not None:
5551
renderer.stop_filter(artist.get_agg_filter())
@@ -929,9 +925,7 @@ def set_agg_filter(self, filter_func):
929925
self._agg_filter = filter_func
930926
self.stale = True
931927

932-
@_api.delete_parameter("3.3", "args")
933-
@_api.delete_parameter("3.3", "kwargs")
934-
def draw(self, renderer, *args, **kwargs):
928+
def draw(self, renderer):
935929
"""
936930
Draw the Artist (and its children) using the given renderer.
937931

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,7 +2980,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
29802980
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
29812981
startangle=0, radius=1, counterclock=True,
29822982
wedgeprops=None, textprops=None, center=(0, 0),
2983-
frame=False, rotatelabels=False, *, normalize=None):
2983+
frame=False, rotatelabels=False, *, normalize=True):
29842984
"""
29852985
Plot a pie chart.
29862986
@@ -3021,19 +3021,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
30213021
shadow : bool, default: False
30223022
Draw a shadow beneath the pie.
30233023
3024-
normalize : None or bool, default: None
3024+
normalize : bool, default: True
30253025
When *True*, always make a full pie by normalizing x so that
30263026
``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
30273027
and raises a `ValueError` for ``sum(x) > 1``.
30283028
3029-
When *None*, defaults to *True* if ``sum(x) >= 1`` and *False* if
3030-
``sum(x) < 1``.
3031-
3032-
Please note that the previous default value of *None* is now
3033-
deprecated, and the default will change to *True* in the next
3034-
release. Please pass ``normalize=False`` explicitly if you want to
3035-
draw a partial pie.
3036-
30373029
labeldistance : float or None, default: 1.1
30383030
The radial distance at which the pie labels are drawn.
30393031
If set to ``None``, label are not drawn, but are stored for use in
@@ -3102,17 +3094,6 @@ def pie(self, x, explode=None, labels=None, colors=None,
31023094

31033095
sx = x.sum()
31043096

3105-
if normalize is None:
3106-
if sx < 1:
3107-
_api.warn_deprecated(
3108-
"3.3", message="normalize=None does not normalize "
3109-
"if the sum is less than 1 but this behavior "
3110-
"is deprecated since %(since)s until %(removal)s. "
3111-
"After the deprecation "
3112-
"period the default value will be normalize=True. "
3113-
"To prevent normalization pass normalize=False ")
3114-
else:
3115-
normalize = True
31163097
if normalize:
31173098
x = x / sx
31183099
elif sx > 1:
@@ -3133,20 +3114,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
31333114
def get_next_color():
31343115
return next(color_cycle)
31353116

3136-
if radius is None:
3137-
_api.warn_deprecated(
3138-
"3.3", message="Support for passing a radius of None to mean "
3139-
"1 is deprecated since %(since)s and will be removed "
3140-
"%(removal)s.")
3141-
radius = 1
3117+
_api.check_isinstance(Number, radius=radius, startangle=startangle)
3118+
if radius <= 0:
3119+
raise ValueError(f'radius must be a positive number, not {radius}')
31423120

31433121
# Starting theta1 is the start fraction of the circle
3144-
if startangle is None:
3145-
_api.warn_deprecated(
3146-
"3.3", message="Support for passing a startangle of None to "
3147-
"mean 0 is deprecated since %(since)s and will be removed "
3148-
"%(removal)s.")
3149-
startangle = 0
31503122
theta1 = startangle / 360
31513123

31523124
if wedgeprops is None:

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,19 +2459,6 @@ def update_datalim(self, xys, updatex=True, updatey=True):
24592459
updatex=updatex, updatey=updatey)
24602460
self.ignore_existing_data_limits = False
24612461

2462-
@_api.deprecated(
2463-
"3.3", alternative="ax.dataLim.set(Bbox.union([ax.dataLim, bounds]))")
2464-
def update_datalim_bounds(self, bounds):
2465-
"""
2466-
Extend the `~.Axes.datalim` Bbox to include the given
2467-
`~matplotlib.transforms.Bbox`.
2468-
2469-
Parameters
2470-
----------
2471-
bounds : `~matplotlib.transforms.Bbox`
2472-
"""
2473-
self.dataLim.set(mtransforms.Bbox.union([self.dataLim, bounds]))
2474-
24752462
def _process_unit_info(self, datasets=None, kwargs=None, *, convert=True):
24762463
"""
24772464
Set axis units based on *datasets* and *kwargs*, and optionally apply
@@ -3009,17 +2996,8 @@ def _update_title_position(self, renderer):
30092996

30102997
# Drawing
30112998
@martist.allow_rasterization
3012-
@_api.delete_parameter(
3013-
"3.3", "inframe", alternative="Axes.redraw_in_frame()")
3014-
def draw(self, renderer=None, inframe=False):
2999+
def draw(self, renderer):
30153000
# docstring inherited
3016-
if renderer is None:
3017-
_api.warn_deprecated(
3018-
"3.3", message="Support for not passing the 'renderer' "
3019-
"parameter to Axes.draw() is deprecated since %(since)s and "
3020-
"will be removed %(removal)s. Use axes.draw_artist(axes) "
3021-
"instead.")
3022-
renderer = self.figure._cachedRenderer
30233001
if renderer is None:
30243002
raise RuntimeError('No renderer defined')
30253003
if not self.get_visible():
@@ -3052,15 +3030,10 @@ def draw(self, renderer=None, inframe=False):
30523030

30533031
self._update_title_position(renderer)
30543032

3055-
if not self.axison or inframe:
3033+
if not self.axison:
30563034
for _axis in self._get_axis_list():
30573035
artists.remove(_axis)
30583036

3059-
if inframe:
3060-
artists.remove(self.title)
3061-
artists.remove(self._left_title)
3062-
artists.remove(self._right_title)
3063-
30643037
if not self.figure.canvas.is_saving():
30653038
artists = [
30663039
a for a in artists

lib/matplotlib/axis.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class Tick(martist.Artist):
5454
The right/top tick label.
5555
5656
"""
57-
@_api.delete_parameter("3.3", "label")
58-
def __init__(self, axes, loc, label=None,
57+
def __init__(self, axes, loc, *,
5958
size=None, # points
6059
width=None,
6160
color=None,
@@ -175,18 +174,6 @@ def __init__(self, axes, loc, label=None,
175174

176175
self._apply_tickdir(tickdir)
177176

178-
for meth, attr in [("_get_tick1line", "tick1line"),
179-
("_get_tick2line", "tick2line"),
180-
("_get_gridline", "gridline"),
181-
("_get_text1", "label1"),
182-
("_get_text2", "label2")]:
183-
overridden_method = _api.deprecate_method_override(
184-
getattr(__class__, meth), self, since="3.3", message="Relying "
185-
f"on {meth} to initialize Tick.{attr} is deprecated since "
186-
f"%(since)s and will not work %(removal)s; please directly "
187-
f"set the attribute in the subclass' __init__ instead.")
188-
if overridden_method:
189-
setattr(self, attr, overridden_method())
190177
for artist in [self.tick1line, self.tick2line, self.gridline,
191178
self.label1, self.label2]:
192179
self._set_artist_props(artist)

lib/matplotlib/projections/polar.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@ def __call__(self):
248248
else:
249249
return np.deg2rad(self.base())
250250

251-
@_api.deprecated("3.3")
252-
def pan(self, numsteps):
253-
return self.base.pan(numsteps)
254-
255251
def refresh(self):
256252
# docstring inherited
257253
return self.base.refresh()
@@ -260,10 +256,6 @@ def view_limits(self, vmin, vmax):
260256
vmin, vmax = np.rad2deg((vmin, vmax))
261257
return np.deg2rad(self.base.view_limits(vmin, vmax))
262258

263-
@_api.deprecated("3.3")
264-
def zoom(self, direction):
265-
return self.base.zoom(direction)
266-
267259

268260
class ThetaTick(maxis.XTick):
269261
"""
@@ -439,19 +431,6 @@ def __call__(self):
439431
return [tick for tick in self.base() if tick > rorigin]
440432
return self.base()
441433

442-
@_api.deprecated("3.3")
443-
def pan(self, numsteps):
444-
return self.base.pan(numsteps)
445-
446-
@_api.deprecated("3.3")
447-
def zoom(self, direction):
448-
return self.base.zoom(direction)
449-
450-
@_api.deprecated("3.3")
451-
def refresh(self):
452-
# docstring inherited
453-
return self.base.refresh()
454-
455434
def nonsingular(self, vmin, vmax):
456435
# docstring inherited
457436
return ((0, 1) if (vmin, vmax) == (-np.inf, np.inf) # Init. limits.
@@ -953,9 +932,7 @@ def get_yaxis_text2_transform(self, pad):
953932
pad_shift = _ThetaShift(self, pad, 'min')
954933
return self._yaxis_text_transform + pad_shift, 'center', halign
955934

956-
@_api.delete_parameter("3.3", "args")
957-
@_api.delete_parameter("3.3", "kwargs")
958-
def draw(self, renderer, *args, **kwargs):
935+
def draw(self, renderer):
959936
self._unstale_viewLim()
960937
thetamin, thetamax = np.rad2deg(self._realViewLim.intervalx)
961938
if thetamin > thetamax:
@@ -999,7 +976,7 @@ def draw(self, renderer, *args, **kwargs):
999976
self.yaxis.reset_ticks()
1000977
self.yaxis.set_clip_path(self.patch)
1001978

1002-
super().draw(renderer, *args, **kwargs)
979+
super().draw(renderer)
1003980

1004981
def _gen_axes_patch(self):
1005982
return mpatches.Wedge((0.5, 0.5), 0.5, 0.0, 360.0)

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2995,7 +2995,7 @@ def pie(
29952995
pctdistance=0.6, shadow=False, labeldistance=1.1,
29962996
startangle=0, radius=1, counterclock=True, wedgeprops=None,
29972997
textprops=None, center=(0, 0), frame=False,
2998-
rotatelabels=False, *, normalize=None, data=None):
2998+
rotatelabels=False, *, normalize=True, data=None):
29992999
return gca().pie(
30003000
x, explode=explode, labels=labels, colors=colors,
30013001
autopct=autopct, pctdistance=pctdistance, shadow=shadow,

0 commit comments

Comments
 (0)