@@ -3083,7 +3083,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
3083
3083
autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
3084
3084
startangle = 0 , radius = 1 , counterclock = True ,
3085
3085
wedgeprops = None , textprops = None , center = (0 , 0 ),
3086
- frame = False , rotatelabels = False , * , normalize = True ):
3086
+ frame = False , rotatelabels = False , * , normalize = True , hatch = None ):
3087
3087
"""
3088
3088
Plot a pie chart.
3089
3089
@@ -3109,29 +3109,34 @@ def pie(self, x, explode=None, labels=None, colors=None,
3109
3109
A sequence of colors through which the pie chart will cycle. If
3110
3110
*None*, will use the colors in the currently active cycle.
3111
3111
3112
+ hatch : str or list, default: None
3113
+ Hatching pattern applied to all pie wedges or sequence of patterns
3114
+ through which the chart will cycle. For a list of valid patterns,
3115
+ see :doc:`/gallery/shapes_and_collections/hatch_style_reference`
3116
+
3117
+ .. versionadded:: 3.7
3118
+
3112
3119
autopct : None or str or callable, default: None
3113
- If not *None*, is a string or function used to label the wedges
3114
- with their numeric value. The label will be placed inside the
3115
- wedge. If it is a format string, the label will be ``fmt % pct``.
3116
- If it is a function, it will be called.
3120
+ If not *None*, *autopct* a string or function used to label the
3121
+ wedges with their numeric value. The label will be placed inside
3122
+ the wedge. If it is a format string, the label will be
3123
+ ``fmt % pct``. If it is a function, it will be called.
3117
3124
3118
3125
pctdistance : float, default: 0.6
3119
- The ratio between the center of each pie slice and the start of
3120
- the text generated by *autopct*. Ignored if *autopct* is *None*.
3126
+ The relative distance along the radius at which the the text
3127
+ generated by *autopct* is drawn. To draw the text outside the pie,
3128
+ set *pctdistance* > 1. This parameter is ignored if *autopct* is
3129
+ ``None``.
3130
+
3131
+ labeldistance : float or None, default: 1.1
3132
+ The relative distance along the radius at which the labels are
3133
+ drawn. To draw the labels inside the pie, set *labeldistance* < 1.
3134
+ If set to ``None``, labels are not drawn but are still stored for
3135
+ use in `.legend`.
3121
3136
3122
3137
shadow : bool, default: False
3123
3138
Draw a shadow beneath the pie.
3124
3139
3125
- normalize : bool, default: True
3126
- When *True*, always make a full pie by normalizing x so that
3127
- ``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
3128
- and raises a `ValueError` for ``sum(x) > 1``.
3129
-
3130
- labeldistance : float or None, default: 1.1
3131
- The radial distance at which the pie labels are drawn.
3132
- If set to ``None``, label are not drawn, but are stored for use in
3133
- ``legend()``
3134
-
3135
3140
startangle : float, default: 0 degrees
3136
3141
The angle by which the start of the pie is rotated,
3137
3142
counterclockwise from the x-axis.
@@ -3143,11 +3148,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
3143
3148
Specify fractions direction, clockwise or counterclockwise.
3144
3149
3145
3150
wedgeprops : dict, default: None
3146
- Dict of arguments passed to the wedge objects making the pie.
3147
- For example, you can pass in ``wedgeprops = {'linewidth': 3}``
3148
- to set the width of the wedge border lines equal to 3.
3149
- For more details, look at the doc/arguments of the wedge object.
3150
- By default, ``clip_on=False`` .
3151
+ Dict of arguments passed to each `.patches.Wedge` of the pie.
3152
+ For example, ``wedgeprops = {'linewidth': 3}`` sets the width of
3153
+ the wedge border lines equal to 3. By default, ``clip_on=False`` .
3154
+ When there is a conflict between these properties and other
3155
+ keywords, properties passed to *wedgeprops* take precedence .
3151
3156
3152
3157
textprops : dict, default: None
3153
3158
Dict of arguments to pass to the text objects.
@@ -3161,6 +3166,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
3161
3166
rotatelabels : bool, default: False
3162
3167
Rotate each label to the angle of the corresponding slice if true.
3163
3168
3169
+ normalize : bool, default: True
3170
+ When *True*, always make a full pie by normalizing x so that
3171
+ ``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
3172
+ and raises a `ValueError` for ``sum(x) > 1``.
3173
+
3164
3174
data : indexable object, optional
3165
3175
DATA_PARAMETER_PLACEHOLDER
3166
3176
@@ -3231,7 +3241,9 @@ def get_next_color():
3231
3241
slices = []
3232
3242
autotexts = []
3233
3243
3234
- for frac , label , expl in zip (x , labels , explode ):
3244
+ hatch = itertools .cycle (np .atleast_1d (hatch ))
3245
+
3246
+ for frac , label , expl , htch in zip (x , labels , explode , hatch ):
3235
3247
x , y = center
3236
3248
theta2 = (theta1 + frac ) if counterclock else (theta1 - frac )
3237
3249
thetam = 2 * np .pi * 0.5 * (theta1 + theta2 )
@@ -3241,6 +3253,7 @@ def get_next_color():
3241
3253
w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
3242
3254
360. * max (theta1 , theta2 ),
3243
3255
facecolor = get_next_color (),
3256
+ hatch = htch ,
3244
3257
clip_on = False ,
3245
3258
label = label )
3246
3259
w .set (** wedgeprops )
0 commit comments