@@ -2335,8 +2335,8 @@ def stem(self, *args, **kwargs):
23352335 return stem_container
23362336
23372337 def pie (self , x , explode = None , labels = None , colors = None ,
2338- autopct = None , pctdistance = 0.6 , shadow = False ,
2339- labeldistance = 1.1 , startangle = None , radius = None ):
2338+ autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
2339+ startangle = None , radius = None , counterclock = True ):
23402340 r"""
23412341 Plot a pie chart.
23422342
@@ -2390,6 +2390,9 @@ def pie(self, x, explode=None, labels=None, colors=None,
23902390 *radius*: [ *None* | scalar ]
23912391 The radius of the pie, if *radius* is *None* it will be set to 1.
23922392
2393+ *counterclock*: [ *False* | *True* ]
2394+ Specify fractions direction, clockwise or counterclockwise.
2395+
23932396 The pie chart will probably look best if the figure and axes are
23942397 square, or the Axes aspect is equal. e.g.::
23952398
@@ -2449,13 +2452,14 @@ def pie(self, x, explode=None, labels=None, colors=None,
24492452 i = 0
24502453 for frac , label , expl in cbook .safezip (x , labels , explode ):
24512454 x , y = center
2452- theta2 = theta1 + frac
2455+ theta2 = ( theta1 + frac ) if counterclock else ( theta1 - frac )
24532456 thetam = 2 * math .pi * 0.5 * (theta1 + theta2 )
24542457 x += expl * math .cos (thetam )
24552458 y += expl * math .sin (thetam )
24562459
2457- w = mpatches .Wedge ((x , y ), radius , 360. * theta1 , 360. * theta2 ,
2458- facecolor = colors [i % len (colors )])
2460+ w = mpatches .Wedge ((x , y ), radius , 360. * min (theta1 , theta2 ),
2461+ 360. * max (theta1 , theta2 ),
2462+ facecolor = colors [i % len (colors )])
24592463 slices .append (w )
24602464 self .add_patch (w )
24612465 w .set_label (label )
0 commit comments