@@ -2901,7 +2901,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
29012901 autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
29022902 startangle = 0 , radius = 1 , counterclock = True ,
29032903 wedgeprops = None , textprops = None , center = (0 , 0 ),
2904- frame = False , rotatelabels = False ):
2904+ frame = False , rotatelabels = False , * , normalize = None ):
29052905 """
29062906 Plot a pie chart.
29072907
@@ -2942,6 +2942,17 @@ def pie(self, x, explode=None, labels=None, colors=None,
29422942 shadow : bool, default: False
29432943 Draw a shadow beneath the pie.
29442944
2945+ normalize: None or bool, default: None
2946+ ``pie()`` used to draw a partial pie if ``sum(x) < 1``. This
2947+ behavior is deprecated and will change to always normalizing the
2948+ values to a full pie by default. If you want to draw a partial pie,
2949+ please pass ``normalize=False`` explicitly.
2950+ When *True*, always make a full pie by normalizing x so that
2951+ ``sum(x) == 1``. When *False*, make a partial pie.
2952+ When *None*, gives the current behavior and warns if
2953+ ``sum(x) < 1``. Please note that passing None to this parameter is
2954+ deprecated.
2955+
29452956 labeldistance : float or None, default: 1.1
29462957 The radial distance at which the pie labels are drawn.
29472958 If set to ``None``, label are not drawn, but are stored for use in
@@ -3010,9 +3021,20 @@ def pie(self, x, explode=None, labels=None, colors=None,
30103021 raise ValueError ("Wedge sizes 'x' must be non negative values" )
30113022
30123023 sx = x .sum ()
3013- if sx > 1 :
3014- x = x / sx
30153024
3025+ if normalize is None :
3026+ if sx < 1 :
3027+ cbook .warn_deprecated (
3028+ "3.1" , message = "normalize=None does not normalize if "
3029+ "the sum is less than 1 "
3030+ "but this behavior is deprecated "
3031+ "since %(since)s. After the deprecation period "
3032+ "the default value will be normalize=True. "
3033+ "To prevent normalization pass normalize=False " )
3034+ else :
3035+ normalize = True
3036+ if normalize :
3037+ x = x / sx
30163038 if labels is None :
30173039 labels = ['' ] * len (x )
30183040 if explode is None :
0 commit comments