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

Skip to content

Commit d6ffe48

Browse files
committed
Remove Axes.pie behaviour deprecated in 3.3.
1 parent c1731b3 commit d6ffe48

File tree

4 files changed

+17
-40
lines changed

4 files changed

+17
-40
lines changed

doc/api/next_api_changes/removals/20331-ES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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+
112
Signatures of `.Artist.draw` and `.Axes.draw`
213
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314
The *inframe* parameter to `.Axes.draw` has been removed. Use

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/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,

lib/matplotlib/tests/test_axes.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,12 +5099,6 @@ def test_pie_get_negative_values():
50995099
ax.pie([5, 5, -3], explode=[0, .1, .2])
51005100

51015101

5102-
def test_normalize_kwarg_warn_pie():
5103-
fig, ax = plt.subplots()
5104-
with pytest.warns(MatplotlibDeprecationWarning):
5105-
ax.pie(x=[0], normalize=None)
5106-
5107-
51085102
def test_normalize_kwarg_pie():
51095103
fig, ax = plt.subplots()
51105104
x = [0.3, 0.3, 0.1]

0 commit comments

Comments
 (0)