Skip to content

Commit 199cea7

Browse files
authored
Merge pull request #8371 from phobson/pie-docstring
DOC: Clean up the pie docstring PR
2 parents fc547f4 + abff9ff commit 199cea7

File tree

1 file changed

+58
-55
lines changed

1 file changed

+58
-55
lines changed

lib/matplotlib/axes/_axes.py

+58-55
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,7 @@ def stem(self, *args, **kwargs):
24692469
return stem_container
24702470

24712471
@_preprocess_data(replace_names=['x', 'explode', 'labels', 'colors'],
2472-
label_namer=None)
2472+
label_namer=None)
24732473
def pie(self, x, explode=None, labels=None, colors=None,
24742474
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
24752475
startangle=None, radius=None, counterclock=True,
@@ -2479,95 +2479,98 @@ def pie(self, x, explode=None, labels=None, colors=None,
24792479
Plot a pie chart.
24802480
24812481
Make a pie chart of array *x*. The fractional area of each
2482-
wedge is given by x/sum(x). If sum(x) <= 1, then the values
2483-
of x give the fractional area directly and the array will not
2484-
be normalized. The wedges are plotted counterclockwise,
2485-
by default starting from the x-axis.
2482+
wedge is given by ``x/sum(x)``. If ``sum(x) <= 1``, then the
2483+
values of x give the fractional area directly and the array
2484+
will not be normalized. The wedges are plotted
2485+
counterclockwise, by default starting from the x-axis.
24862486
2487-
Keyword arguments:
2487+
Parameters
2488+
----------
2489+
x : array-like
2490+
The input array used to make the pie chart.
24882491
2489-
*explode*: [ *None* | len(x) sequence ]
2492+
explode : array-like, optional, default: None
24902493
If not *None*, is a ``len(x)`` array which specifies the
24912494
fraction of the radius with which to offset each wedge.
24922495
2493-
*colors*: [ *None* | color sequence ]
2496+
labels : list, optional, default: None
2497+
A sequence of strings providing the labels for each wedge
2498+
2499+
colors : array-like, optional, default: None
24942500
A sequence of matplotlib color args through which the pie chart
24952501
will cycle. If `None`, will use the colors in the currently
24962502
active cycle.
24972503
2498-
*labels*: [ *None* | len(x) sequence of strings ]
2499-
A sequence of strings providing the labels for each wedge
2500-
2501-
*autopct*: [ *None* | format string | format function ]
2504+
autopct : None (default), string, or function, optional
25022505
If not *None*, is a string or function used to label the wedges
25032506
with their numeric value. The label will be placed inside the
25042507
wedge. If it is a format string, the label will be ``fmt%pct``.
25052508
If it is a function, it will be called.
25062509
2507-
*pctdistance*: scalar
2510+
pctdistance : float, optional, default: 0.6
25082511
The ratio between the center of each pie slice and the
25092512
start of the text generated by *autopct*. Ignored if
2510-
*autopct* is *None*; default is 0.6.
2513+
*autopct* is *None*.
25112514
2512-
*labeldistance*: scalar
2513-
The radial distance at which the pie labels are drawn
2514-
2515-
*shadow*: [ *False* | *True* ]
2515+
shadow : bool, optional, default: False
25162516
Draw a shadow beneath the pie.
25172517
2518-
*startangle*: [ *None* | Offset angle ]
2518+
labeldistance : float, optional, default: 1.1
2519+
The radial distance at which the pie labels are drawn
2520+
2521+
startangle : float, optional, default: None
25192522
If not *None*, rotates the start of the pie chart by *angle*
25202523
degrees counterclockwise from the x-axis.
25212524
2522-
*radius*: [ *None* | scalar ]
2523-
The radius of the pie, if *radius* is *None* it will be set to 1.
2525+
radius : float, optional, default: None
2526+
The radius of the pie, if *radius* is *None* it will be set to 1.
25242527
2525-
*counterclock*: [ *False* | *True* ]
2528+
counterclock : bool, optional, default: True
25262529
Specify fractions direction, clockwise or counterclockwise.
25272530
2528-
*wedgeprops*: [ *None* | dict of key value pairs ]
2531+
wedgeprops : dict, optional, default: None
25292532
Dict of arguments passed to the wedge objects making the pie.
2530-
For example, you can pass in wedgeprops = { 'linewidth' : 3 }
2533+
For example, you can pass in``wedgeprops = {'linewidth': 3}``
25312534
to set the width of the wedge border lines equal to 3.
25322535
For more details, look at the doc/arguments of the wedge object.
2533-
By default `clip_on=False`.
2536+
By default ``clip_on=False``.
25342537
2535-
*textprops*: [ *None* | dict of key value pairs ]
2538+
textprops : dict, optional, default: None
25362539
Dict of arguments to pass to the text objects.
25372540
2538-
*center*: [ (0,0) | sequence of 2 scalars ]
2539-
Center position of the chart.
2540-
2541-
*frame*: [ *False* | *True* ]
2542-
Plot axes frame with the chart.
2541+
center : list of float, optional, default: (0, 0)
2542+
Center position of the chart. Takes value (0, 0) or is a
2543+
sequence of 2 scalars.
25432544
2544-
*rotatelabels*: [ *False* | *True* ]
2545-
Rotate each label to the angle of the corresponding slice.
2545+
frame : bool, optional, default: False
2546+
Plot axes frame with the chart if true.
25462547
2547-
The pie chart will probably look best if the figure and axes are
2548-
square, or the Axes aspect is equal. e.g.::
2548+
rotatelabels : bool, optional, default: False
2549+
Rotate each label to the angle of the corresponding slice if true.
25492550
2550-
figure(figsize=(8,8))
2551-
ax = axes([0.1, 0.1, 0.8, 0.8])
2551+
Returns
2552+
-------
2553+
patches : list
2554+
A sequence of :class:`matplotlib.patches.Wedge` instances
25522555
2553-
or::
2556+
texts : list
2557+
A is a list of the label :class:`matplotlib.text.Text` instances.
25542558
2555-
axes(aspect=1)
2559+
autotexts : list
2560+
A is a list of :class:`~matplotlib.text.Text` instances for the
2561+
numeric labels. Is returned only if parameter *autopct* is
2562+
not *None*.
25562563
2557-
Return value:
2558-
If *autopct* is *None*, return the tuple (*patches*, *texts*):
2564+
Notes
2565+
-----
2566+
The pie chart will probably look best if the figure and axes are
2567+
square, or the Axes aspect is equal.
25592568
2560-
- *patches* is a sequence of
2561-
:class:`matplotlib.patches.Wedge` instances
2569+
Examples
2570+
--------
2571+
.. plot:: mpl_examples/pie_and_polar_charts/pie_demo_features.py
25622572
2563-
- *texts* is a list of the label
2564-
:class:`matplotlib.text.Text` instances.
25652573
2566-
If *autopct* is not *None*, return the tuple (*patches*,
2567-
*texts*, *autotexts*), where *patches* and *texts* are as
2568-
above, and *autotexts* is a list of
2569-
:class:`~matplotlib.text.Text` instances for the numeric
2570-
labels.
25712574
"""
25722575

25732576
x = np.array(x, np.float32)
@@ -2623,9 +2626,9 @@ def get_next_color():
26232626
y += expl * math.sin(thetam)
26242627

26252628
w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
2626-
360. * max(theta1, theta2),
2627-
facecolor=get_next_color(),
2628-
**wedgeprops)
2629+
360. * max(theta1, theta2),
2630+
facecolor=get_next_color(),
2631+
**wedgeprops)
26292632
slices.append(w)
26302633
self.add_patch(w)
26312634
w.set_label(label)
@@ -2682,9 +2685,9 @@ def get_next_color():
26822685
self.set_frame_on(False)
26832686

26842687
self.set_xlim((-1.25 + center[0],
2685-
1.25 + center[0]))
2688+
1.25 + center[0]))
26862689
self.set_ylim((-1.25 + center[1],
2687-
1.25 + center[1]))
2690+
1.25 + center[1]))
26882691
self.set_xticks([])
26892692
self.set_yticks([])
26902693

0 commit comments

Comments
 (0)