@@ -2899,7 +2899,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2899
2899
@_preprocess_data (replace_names = ["x" , "explode" , "labels" , "colors" ])
2900
2900
def pie (self , x , explode = None , labels = None , colors = None ,
2901
2901
autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
2902
- startangle = None , radius = None , counterclock = True ,
2902
+ startangle = 0 , radius = 1 , counterclock = True ,
2903
2903
wedgeprops = None , textprops = None , center = (0 , 0 ),
2904
2904
frame = False , rotatelabels = False ):
2905
2905
"""
@@ -2932,7 +2932,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
2932
2932
autopct : None or str or callable, default: None
2933
2933
If not *None*, is a string or function used to label the wedges
2934
2934
with their numeric value. The label will be placed inside the
2935
- wedge. If it is a format string, the label will be ``fmt% pct``.
2935
+ wedge. If it is a format string, the label will be ``fmt % pct``.
2936
2936
If it is a function, it will be called.
2937
2937
2938
2938
pctdistance : float, default: 0.6
@@ -2947,12 +2947,12 @@ def pie(self, x, explode=None, labels=None, colors=None,
2947
2947
If set to ``None``, label are not drawn, but are stored for use in
2948
2948
``legend()``
2949
2949
2950
- startangle : float, default: None
2951
- If not *None*, rotates the start of the pie chart by *angle*
2952
- degrees counterclockwise from the x-axis.
2950
+ startangle : float, default: 0 degrees
2951
+ The angle by which the start of the pie is rotated,
2952
+ counterclockwise from the x-axis.
2953
2953
2954
- radius : float, default: None
2955
- The radius of the pie, if *radius* is *None* it will be set to 1 .
2954
+ radius : float, default: 1
2955
+ The radius of the pie.
2956
2956
2957
2957
counterclock : bool, default: True
2958
2958
Specify fractions direction, clockwise or counterclockwise.
@@ -3030,22 +3030,25 @@ def get_next_color():
3030
3030
return next (color_cycle )
3031
3031
3032
3032
if radius is None :
3033
+ cbook .warn_deprecated (
3034
+ "3.3" , message = "Support for passing a radius of None to mean "
3035
+ "1 is deprecated since %(since)s and will be removed "
3036
+ "%(removal)s." )
3033
3037
radius = 1
3034
3038
3035
3039
# Starting theta1 is the start fraction of the circle
3036
3040
if startangle is None :
3037
- theta1 = 0
3038
- else :
3039
- theta1 = startangle / 360.0
3041
+ cbook .warn_deprecated (
3042
+ "3.3" , message = "Support for passing a startangle of None to "
3043
+ "mean 0 is deprecated since %(since)s and will be removed "
3044
+ "%(removal)s." )
3045
+ startangle = 0
3046
+ theta1 = startangle / 360
3040
3047
3041
- # set default values in wedge_prop
3042
3048
if wedgeprops is None :
3043
3049
wedgeprops = {}
3044
- wedgeprops .setdefault ('clip_on' , False )
3045
-
3046
3050
if textprops is None :
3047
3051
textprops = {}
3048
- textprops .setdefault ('clip_on' , False )
3049
3052
3050
3053
texts = []
3051
3054
slices = []
@@ -3061,18 +3064,17 @@ def get_next_color():
3061
3064
w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
3062
3065
360. * max (theta1 , theta2 ),
3063
3066
facecolor = get_next_color (),
3064
- ** wedgeprops )
3067
+ clip_on = False ,
3068
+ label = label )
3069
+ w .set (** wedgeprops )
3065
3070
slices .append (w )
3066
3071
self .add_patch (w )
3067
- w .set_label (label )
3068
3072
3069
3073
if shadow :
3070
- # make sure to add a shadow after the call to
3071
- # add_patch so the figure and transform props will be
3072
- # set
3074
+ # Make sure to add a shadow after the call to add_patch so the
3075
+ # figure and transform props will be set.
3073
3076
shad = mpatches .Shadow (w , - 0.02 , - 0.02 )
3074
- shad .set_zorder (0.9 * w .get_zorder ())
3075
- shad .set_label ('_nolegend_' )
3077
+ shad .set (zorder = 0.9 * w .get_zorder (), label = '_nolegend_' )
3076
3078
self .add_patch (shad )
3077
3079
3078
3080
if labeldistance is not None :
@@ -3085,14 +3087,13 @@ def get_next_color():
3085
3087
label_alignment_v = 'bottom' if yt > 0 else 'top'
3086
3088
label_rotation = (np .rad2deg (thetam )
3087
3089
+ (0 if xt > 0 else 180 ))
3088
- props = dict (horizontalalignment = label_alignment_h ,
3089
- verticalalignment = label_alignment_v ,
3090
- rotation = label_rotation ,
3091
- size = rcParams ['xtick.labelsize' ])
3092
- props .update (textprops )
3093
-
3094
- t = self .text (xt , yt , label , ** props )
3095
-
3090
+ t = self .text (xt , yt , label ,
3091
+ clip_on = False ,
3092
+ horizontalalignment = label_alignment_h ,
3093
+ verticalalignment = label_alignment_v ,
3094
+ rotation = label_rotation ,
3095
+ size = rcParams ['xtick.labelsize' ])
3096
+ t .set (** textprops )
3096
3097
texts .append (t )
3097
3098
3098
3099
if autopct is not None :
@@ -3105,25 +3106,19 @@ def get_next_color():
3105
3106
else :
3106
3107
raise TypeError (
3107
3108
'autopct must be callable or a format string' )
3108
-
3109
- props = dict (horizontalalignment = 'center' ,
3110
- verticalalignment = 'center' )
3111
- props .update (textprops )
3112
- t = self .text (xt , yt , s , ** props )
3113
-
3109
+ t = self .text (xt , yt , s ,
3110
+ clip_on = False ,
3111
+ horizontalalignment = 'center' ,
3112
+ verticalalignment = 'center' )
3113
+ t .set (** textprops )
3114
3114
autotexts .append (t )
3115
3115
3116
3116
theta1 = theta2
3117
3117
3118
3118
if not frame :
3119
- self .set_frame_on (False )
3120
-
3121
- self .set_xlim ((- 1.25 + center [0 ],
3122
- 1.25 + center [0 ]))
3123
- self .set_ylim ((- 1.25 + center [1 ],
3124
- 1.25 + center [1 ]))
3125
- self .set_xticks ([])
3126
- self .set_yticks ([])
3119
+ self .set (frame_on = False , xticks = [], yticks = [],
3120
+ xlim = (- 1.25 + center [0 ], 1.25 + center [0 ]),
3121
+ ylim = (- 1.25 + center [1 ], 1.25 + center [1 ]))
3127
3122
3128
3123
if autopct is None :
3129
3124
return slices , texts
0 commit comments