Skip to content

DOC: Clean up the pie docstring PR #8371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 58 additions & 55 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2469,7 +2469,7 @@ def stem(self, *args, **kwargs):
return stem_container

@_preprocess_data(replace_names=['x', 'explode', 'labels', 'colors'],
label_namer=None)
label_namer=None)
def pie(self, x, explode=None, labels=None, colors=None,
autopct=None, pctdistance=0.6, shadow=False, labeldistance=1.1,
startangle=None, radius=None, counterclock=True,
Expand All @@ -2479,95 +2479,98 @@ def pie(self, x, explode=None, labels=None, colors=None,
Plot a pie chart.

Make a pie chart of array *x*. The fractional area of each
wedge is given by x/sum(x). If sum(x) <= 1, then the values
of x give the fractional area directly and the array will not
be normalized. The wedges are plotted counterclockwise,
by default starting from the x-axis.
wedge is given by ``x/sum(x)``. If ``sum(x) <= 1``, then the
values of x give the fractional area directly and the array
will not be normalized. The wedges are plotted
counterclockwise, by default starting from the x-axis.

Keyword arguments:
Parameters
----------
x : array-like
The input array used to make the pie chart.

*explode*: [ *None* | len(x) sequence ]
explode : array-like, optional, default: None
If not *None*, is a ``len(x)`` array which specifies the
fraction of the radius with which to offset each wedge.

*colors*: [ *None* | color sequence ]
labels : list, optional, default: None
A sequence of strings providing the labels for each wedge

colors : array-like, optional, default: None
A sequence of matplotlib color args through which the pie chart
will cycle. If `None`, will use the colors in the currently
active cycle.

*labels*: [ *None* | len(x) sequence of strings ]
A sequence of strings providing the labels for each wedge

*autopct*: [ *None* | format string | format function ]
autopct : None (default), string, or function, optional
If not *None*, is a string or function used to label the wedges
with their numeric value. The label will be placed inside the
wedge. If it is a format string, the label will be ``fmt%pct``.
If it is a function, it will be called.

*pctdistance*: scalar
pctdistance : float, optional, default: 0.6
The ratio between the center of each pie slice and the
start of the text generated by *autopct*. Ignored if
*autopct* is *None*; default is 0.6.
*autopct* is *None*.

*labeldistance*: scalar
The radial distance at which the pie labels are drawn

*shadow*: [ *False* | *True* ]
shadow : bool, optional, default: False
Draw a shadow beneath the pie.

*startangle*: [ *None* | Offset angle ]
labeldistance : float, optional, default: 1.1
The radial distance at which the pie labels are drawn

startangle : float, optional, default: None
If not *None*, rotates the start of the pie chart by *angle*
degrees counterclockwise from the x-axis.

*radius*: [ *None* | scalar ]
The radius of the pie, if *radius* is *None* it will be set to 1.
radius : float, optional, default: None
The radius of the pie, if *radius* is *None* it will be set to 1.

*counterclock*: [ *False* | *True* ]
counterclock : bool, optional, default: True
Specify fractions direction, clockwise or counterclockwise.

*wedgeprops*: [ *None* | dict of key value pairs ]
wedgeprops : dict, optional, default: None
Dict of arguments passed to the wedge objects making the pie.
For example, you can pass in wedgeprops = { 'linewidth' : 3 }
For example, you can pass in``wedgeprops = {'linewidth': 3}``
to set the width of the wedge border lines equal to 3.
For more details, look at the doc/arguments of the wedge object.
By default `clip_on=False`.
By default ``clip_on=False``.

*textprops*: [ *None* | dict of key value pairs ]
textprops : dict, optional, default: None
Dict of arguments to pass to the text objects.

*center*: [ (0,0) | sequence of 2 scalars ]
Center position of the chart.

*frame*: [ *False* | *True* ]
Plot axes frame with the chart.
center : list of float, optional, default: (0, 0)
Center position of the chart. Takes value (0, 0) or is a
sequence of 2 scalars.

*rotatelabels*: [ *False* | *True* ]
Rotate each label to the angle of the corresponding slice.
frame : bool, optional, default: False
Plot axes frame with the chart if true.

The pie chart will probably look best if the figure and axes are
square, or the Axes aspect is equal. e.g.::
rotatelabels : bool, optional, default: False
Rotate each label to the angle of the corresponding slice if true.

figure(figsize=(8,8))
ax = axes([0.1, 0.1, 0.8, 0.8])
Returns
-------
patches : list
A sequence of :class:`matplotlib.patches.Wedge` instances

or::
texts : list
A is a list of the label :class:`matplotlib.text.Text` instances.

axes(aspect=1)
autotexts : list
A is a list of :class:`~matplotlib.text.Text` instances for the
numeric labels. Is returned only if parameter *autopct* is
not *None*.

Return value:
If *autopct* is *None*, return the tuple (*patches*, *texts*):
Notes
-----
The pie chart will probably look best if the figure and axes are
square, or the Axes aspect is equal.

- *patches* is a sequence of
:class:`matplotlib.patches.Wedge` instances
Examples
--------
.. plot:: mpl_examples/pie_and_polar_charts/pie_demo_features.py

- *texts* is a list of the label
:class:`matplotlib.text.Text` instances.

If *autopct* is not *None*, return the tuple (*patches*,
*texts*, *autotexts*), where *patches* and *texts* are as
above, and *autotexts* is a list of
:class:`~matplotlib.text.Text` instances for the numeric
labels.
"""

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

w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),
360. * max(theta1, theta2),
facecolor=get_next_color(),
**wedgeprops)
360. * max(theta1, theta2),
facecolor=get_next_color(),
**wedgeprops)
slices.append(w)
self.add_patch(w)
w.set_label(label)
Expand Down Expand Up @@ -2682,9 +2685,9 @@ def get_next_color():
self.set_frame_on(False)

self.set_xlim((-1.25 + center[0],
1.25 + center[0]))
1.25 + center[0]))
self.set_ylim((-1.25 + center[1],
1.25 + center[1]))
1.25 + center[1]))
self.set_xticks([])
self.set_yticks([])

Expand Down