@@ -2475,7 +2475,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
24752475 autopct = None , pctdistance = 0.6 , shadow = False , labeldistance = 1.1 ,
24762476 startangle = None , radius = None , counterclock = True ,
24772477 wedgeprops = None , textprops = None , center = (0 , 0 ),
2478- frame = False , labelrotate = False ):
2478+ frame = False , rotatelabels = False ):
24792479 r"""
24802480 Plot a pie chart.
24812481
@@ -2542,7 +2542,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
25422542 *frame*: [ *False* | *True* ]
25432543 Plot axes frame with the chart.
25442544
2545- *labelrotate *: [ *False* | *True* ]
2545+ *rotatelabels *: [ *False* | *True* ]
25462546 Rotate each label to the angle of the corresponding slice.
25472547
25482548 The pie chart will probably look best if the figure and axes are
@@ -2620,7 +2620,6 @@ def get_next_color():
26202620 x , y = center
26212621 theta2 = (theta1 + frac ) if counterclock else (theta1 - frac )
26222622 thetam = 2 * math .pi * 0.5 * (theta1 + theta2 )
2623- thetamd = 360 * 0.5 * (theta1 + theta2 )
26242623 x += expl * math .cos (thetam )
26252624 y += expl * math .sin (thetam )
26262625
@@ -2643,15 +2642,17 @@ def get_next_color():
26432642
26442643 xt = x + labeldistance * radius * math .cos (thetam )
26452644 yt = y + labeldistance * radius * math .sin (thetam )
2646- label_alignment = xt > 0 and 'left' or 'right'
2645+ label_alignment_h = xt > 0 and 'left' or 'right'
2646+ label_alignment_v = 'center'
26472647 label_rotation = 'horizontal'
2648- if labelrotate :
2649- label_rotation = thetamd + (0 if xt > 0 else 180 )
2648+ if rotatelabels :
2649+ label_alignment_v = yt > 0 and 'bottom' or 'top'
2650+ label_rotation = np .rad2deg (thetam ) + (0 if xt > 0 else 180 )
26502651
26512652 t = self .text (xt , yt , label ,
26522653 size = rcParams ['xtick.labelsize' ],
2653- horizontalalignment = label_alignment ,
2654- verticalalignment = 'center' ,
2654+ horizontalalignment = label_alignment_h ,
2655+ verticalalignment = label_alignment_v ,
26552656 rotation = label_rotation ,
26562657 ** textprops )
26572658
0 commit comments