MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / pie_label

Method pie_label

lib/matplotlib/axes/_axes.py:3778–3875  ·  view source on GitHub ↗

Label a pie chart. .. versionadded:: 3.11 Adds labels to wedges in the given `.PieContainer`. Parameters ---------- container : `.PieContainer` Container with all the wedges, likely returned from `.pie`. labels : str or list of

(self, container, /, labels, *, distance=0.6,
                  textprops=None, rotate=False, alignment='auto')

Source from the content-addressed store, hash-verified

3776 return pc
3777
3778 def pie_label(self, container, /, labels, *, distance=0.6,
3779 textprops=None, rotate=False, alignment='auto'):
3780 """
3781 Label a pie chart.
3782
3783 .. versionadded:: 3.11
3784
3785 Adds labels to wedges in the given `.PieContainer`.
3786
3787 Parameters
3788 ----------
3789 container : `.PieContainer`
3790 Container with all the wedges, likely returned from `.pie`.
3791
3792 labels : str or list of str
3793 A sequence of strings providing the labels for each wedge, or a format
3794 string with ``absval`` and/or ``frac`` placeholders. For example, to label
3795 each wedge with its value and the percentage in brackets::
3796
3797 wedge_labels="{absval:d} ({frac:.0%})"
3798
3799 distance : float, default: 0.6
3800 The radial position of the labels, relative to the pie radius. Values > 1
3801 are outside the wedge and values < 1 are inside the wedge.
3802
3803 textprops : dict, default: None
3804 Dict of arguments to pass to the `.Text` objects.
3805
3806 rotate : bool, default: False
3807 Rotate each label to the angle of the corresponding slice if true.
3808
3809 alignment : {'center', 'outer', 'auto'}, default: 'auto'
3810 Controls the horizontal alignment of the text objects relative to their
3811 nominal position.
3812
3813 - 'center': The labels are centered on their points.
3814 - 'outer': Labels are aligned away from the center of the pie, i.e., labels
3815 on the left side of the pie are right-aligned and labels on the right
3816 side are left-aligned.
3817 - 'auto': Translates to 'outer' if *distance* > 1 (so that the labels do not
3818 overlap the wedges) and 'center' if *distance* < 1.
3819
3820 If *rotate* is True, the vertical alignment is also affected in an
3821 analogous way.
3822
3823 - 'center': The labels are centered on their points.
3824 - 'outer': Labels are aligned away from the center of the pie, i.e., labels
3825 on the top half of the pie are bottom-aligned and labels on the bottom
3826 half are top-aligned.
3827
3828 Returns
3829 -------
3830 list
3831 A list of the label `.Text` instances.
3832 """
3833 _api.check_in_list(['center', 'outer', 'auto'], alignment=alignment)
3834 if alignment == 'auto':
3835 alignment = 'outer' if distance > 1 else 'center'

Callers 8

pieMethod · 0.95
pie_labelFunction · 0.80
test_piecontainer_removeFunction · 0.80
test_pie_label_formatterFunction · 0.80
test_pie_label_failFunction · 0.80
pie_label.pyFile · 0.80

Calls 4

textMethod · 0.95
add_textsMethod · 0.80
getMethod · 0.45
setMethod · 0.45

Tested by 4

test_piecontainer_removeFunction · 0.64
test_pie_label_formatterFunction · 0.64
test_pie_label_failFunction · 0.64