@@ -3075,7 +3075,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
3075
3075
autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
3076
3076
startangle = 0 , radius = 1 , counterclock = True ,
3077
3077
wedgeprops = None , textprops = None , center = (0 , 0 ),
3078
- frame = False , rotatelabels = False , * , normalize = True ):
3078
+ frame = False , rotatelabels = False , * , normalize = True , hatch = None ):
3079
3079
"""
3080
3080
Plot a pie chart.
3081
3081
@@ -3101,29 +3101,34 @@ def pie(self, x, explode=None, labels=None, colors=None,
3101
3101
A sequence of colors through which the pie chart will cycle. If
3102
3102
*None*, will use the colors in the currently active cycle.
3103
3103
3104
+ hatch : str or list, default: None
3105
+ Hatching pattern applied to all pie wedges or sequence of patterns
3106
+ through which the chart will cycle. For a list of valid patterns,
3107
+ see :doc:`/gallery/shapes_and_collections/hatch_style_reference`.
3108
+
3109
+ .. versionadded:: 3.7
3110
+
3104
3111
autopct : None or str or callable, default: None
3105
- If not *None*, is a string or function used to label the wedges
3106
- with their numeric value. The label will be placed inside the
3107
- wedge. If it is a format string, the label will be ``fmt % pct``.
3108
- If it is a function, it will be called.
3112
+ If not *None*, *autopct* is a string or function used to label the
3113
+ wedges with their numeric value. The label will be placed inside
3114
+ the wedge. If *autopct* is a format string, the label will be
3115
+ ``fmt % pct``. If *autopct* is a function, then it will be called.
3109
3116
3110
3117
pctdistance : float, default: 0.6
3111
- The ratio between the center of each pie slice and the start of
3112
- the text generated by *autopct*. Ignored if *autopct* is *None*.
3118
+ The relative distance along the radius at which the the text
3119
+ generated by *autopct* is drawn. To draw the text outside the pie,
3120
+ set *pctdistance* > 1. This parameter is ignored if *autopct* is
3121
+ ``None``.
3122
+
3123
+ labeldistance : float or None, default: 1.1
3124
+ The relative distance along the radius at which the labels are
3125
+ drawn. To draw the labels inside the pie, set *labeldistance* < 1.
3126
+ If set to ``None``, labels are not drawn but are still stored for
3127
+ use in `.legend`.
3113
3128
3114
3129
shadow : bool, default: False
3115
3130
Draw a shadow beneath the pie.
3116
3131
3117
- normalize : bool, default: True
3118
- When *True*, always make a full pie by normalizing x so that
3119
- ``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
3120
- and raises a `ValueError` for ``sum(x) > 1``.
3121
-
3122
- labeldistance : float or None, default: 1.1
3123
- The radial distance at which the pie labels are drawn.
3124
- If set to ``None``, label are not drawn, but are stored for use in
3125
- ``legend()``
3126
-
3127
3132
startangle : float, default: 0 degrees
3128
3133
The angle by which the start of the pie is rotated,
3129
3134
counterclockwise from the x-axis.
@@ -3135,11 +3140,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
3135
3140
Specify fractions direction, clockwise or counterclockwise.
3136
3141
3137
3142
wedgeprops : dict, default: None
3138
- Dict of arguments passed to the wedge objects making the pie.
3139
- For example, you can pass in ``wedgeprops = {'linewidth': 3}``
3140
- to set the width of the wedge border lines equal to 3.
3141
- For more details, look at the doc/arguments of the wedge object.
3142
- By default, ``clip_on=False`` .
3143
+ Dict of arguments passed to each `.patches.Wedge` of the pie.
3144
+ For example, ``wedgeprops = {'linewidth': 3}`` sets the width of
3145
+ the wedge border lines equal to 3. By default, ``clip_on=False`` .
3146
+ When there is a conflict between these properties and other
3147
+ keywords, properties passed to *wedgeprops* take precedence .
3143
3148
3144
3149
textprops : dict, default: None
3145
3150
Dict of arguments to pass to the text objects.
@@ -3153,6 +3158,11 @@ def pie(self, x, explode=None, labels=None, colors=None,
3153
3158
rotatelabels : bool, default: False
3154
3159
Rotate each label to the angle of the corresponding slice if true.
3155
3160
3161
+ normalize : bool, default: True
3162
+ When *True*, always make a full pie by normalizing x so that
3163
+ ``sum(x) == 1``. *False* makes a partial pie if ``sum(x) <= 1``
3164
+ and raises a `ValueError` for ``sum(x) > 1``.
3165
+
3156
3166
data : indexable object, optional
3157
3167
DATA_PARAMETER_PLACEHOLDER
3158
3168
@@ -3207,6 +3217,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
3207
3217
def get_next_color ():
3208
3218
return next (color_cycle )
3209
3219
3220
+ hatch_cycle = itertools .cycle (np .atleast_1d (hatch ))
3221
+
3210
3222
_api .check_isinstance (Number , radius = radius , startangle = startangle )
3211
3223
if radius <= 0 :
3212
3224
raise ValueError (f'radius must be a positive number, not { radius } ' )
@@ -3233,6 +3245,7 @@ def get_next_color():
3233
3245
w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
3234
3246
360. * max (theta1 , theta2 ),
3235
3247
facecolor = get_next_color (),
3248
+ hatch = next (hatch_cycle ),
3236
3249
clip_on = False ,
3237
3250
label = label )
3238
3251
w .set (** wedgeprops )
0 commit comments