1
+ import collections
1
2
import functools
2
3
import itertools
3
4
import logging
@@ -3116,11 +3117,12 @@ def pie(self, x, explode=None, labels=None, colors=None,
3116
3117
counterclock : bool, default: True
3117
3118
Specify fractions direction, clockwise or counterclockwise.
3118
3119
3119
- wedgeprops : dict, default: None
3120
- Dict of arguments passed to the wedge objects making the pie.
3121
- For example, you can pass in ``wedgeprops = {'linewidth': 3}``
3122
- to set the width of the wedge border lines equal to 3.
3123
- For more details, look at the doc/arguments of the wedge object.
3120
+ wedgeprops : dict, list of dict, default: None
3121
+ Dict of arguments passed to each `matplotlib.patches.Wedge` of the
3122
+ pie. For example, you can pass in ``wedgeprops = {'linewidth': 3}``
3123
+ to set the width of the wedge border lines equal to 3. You can also
3124
+ pass in a list of dicts to set each individual wedge object.
3125
+ For a list of properties, see `matplotlib.patches.Wedge`.
3124
3126
By default ``clip_on=False``.
3125
3127
3126
3128
textprops : dict, default: None
@@ -3205,7 +3207,14 @@ def get_next_color():
3205
3207
slices = []
3206
3208
autotexts = []
3207
3209
3208
- for frac , label , expl in zip (x , labels , explode ):
3210
+ if isinstance (wedgeprops , collections .abc .Sequence ):
3211
+ if len (wedgeprops ) != len (x ):
3212
+ raise ValueError (f'wedgeprops length={ len (wedgeprops )} '
3213
+ f' and input length={ len (x )} are not equal' )
3214
+ else :
3215
+ wedgeprops = itertools .repeat (wedgeprops )
3216
+
3217
+ for frac , label , expl , wprops in zip (x , labels , explode , wedgeprops ):
3209
3218
x , y = center
3210
3219
theta2 = (theta1 + frac ) if counterclock else (theta1 - frac )
3211
3220
thetam = 2 * np .pi * 0.5 * (theta1 + theta2 )
@@ -3217,7 +3226,7 @@ def get_next_color():
3217
3226
facecolor = get_next_color (),
3218
3227
clip_on = False ,
3219
3228
label = label )
3220
- w .set (** wedgeprops )
3229
+ w .set (** wprops )
3221
3230
slices .append (w )
3222
3231
self .add_patch (w )
3223
3232
0 commit comments