@@ -2685,8 +2685,10 @@ def pie(self, x, explode=None, labels=None, colors=None,
2685
2685
shadow : bool, optional, default: False
2686
2686
Draw a shadow beneath the pie.
2687
2687
2688
- labeldistance : float, optional, default: 1.1
2689
- The radial distance at which the pie labels are drawn
2688
+ labeldistance : float or None, optional, default: 1.1
2689
+ The radial distance at which the pie labels are drawn.
2690
+ If set to ``None``, label are not drawn, but are stored for use in
2691
+ ``legend()``
2690
2692
2691
2693
startangle : float, optional, default: None
2692
2694
If not *None*, rotates the start of the pie chart by *angle*
@@ -2808,23 +2810,25 @@ def get_next_color():
2808
2810
shad .set_label ('_nolegend_' )
2809
2811
self .add_patch (shad )
2810
2812
2811
- xt = x + labeldistance * radius * math .cos (thetam )
2812
- yt = y + labeldistance * radius * math .sin (thetam )
2813
- label_alignment_h = xt > 0 and 'left' or 'right'
2814
- label_alignment_v = 'center'
2815
- label_rotation = 'horizontal'
2816
- if rotatelabels :
2817
- label_alignment_v = yt > 0 and 'bottom' or 'top'
2818
- label_rotation = np .rad2deg (thetam ) + (0 if xt > 0 else 180 )
2819
- props = dict (horizontalalignment = label_alignment_h ,
2820
- verticalalignment = label_alignment_v ,
2821
- rotation = label_rotation ,
2822
- size = rcParams ['xtick.labelsize' ])
2823
- props .update (textprops )
2824
-
2825
- t = self .text (xt , yt , label , ** props )
2826
-
2827
- texts .append (t )
2813
+ if labeldistance is not None :
2814
+ xt = x + labeldistance * radius * math .cos (thetam )
2815
+ yt = y + labeldistance * radius * math .sin (thetam )
2816
+ label_alignment_h = xt > 0 and 'left' or 'right'
2817
+ label_alignment_v = 'center'
2818
+ label_rotation = 'horizontal'
2819
+ if rotatelabels :
2820
+ label_alignment_v = yt > 0 and 'bottom' or 'top'
2821
+ label_rotation = np .rad2deg (thetam ) + (0 if xt > 0
2822
+ else 180 )
2823
+ props = dict (horizontalalignment = label_alignment_h ,
2824
+ verticalalignment = label_alignment_v ,
2825
+ rotation = label_rotation ,
2826
+ size = rcParams ['xtick.labelsize' ])
2827
+ props .update (textprops )
2828
+
2829
+ t = self .text (xt , yt , label , ** props )
2830
+
2831
+ texts .append (t )
2828
2832
2829
2833
if autopct is not None :
2830
2834
xt = x + pctdistance * radius * math .cos (thetam )
0 commit comments