Skip to content

Convert docstring of Axes.pie() into numpydoc #8357

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

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ea9250d
numpydocstring added
kahnchana Mar 21, 2017
d4d912b
.
kahnchana Mar 21, 2017
ce79bfe
Merge remote-tracking branch 'refs/remotes/matplotlib/master' into do…
kahnchana Mar 22, 2017
492b0ac
Revert "numpydocstring added"
kahnchana Mar 22, 2017
50aa3ff
Docstring to Numpydoc
kahnchana Mar 22, 2017
17570af
Merge remote-tracking branch 'refs/remotes/matplotlib/master'
kahnchana Mar 22, 2017
9b6c50b
Merge remote-tracking branch 'refs/remotes/origin/master' into docstring
kahnchana Mar 22, 2017
8df19bd
FIX small nitpicks
kahnchana Mar 22, 2017
f570978
removed duplicate matplotlib.transforms import
sindunuragarp Mar 16, 2017
027cbae
Standardized matplotlib transforms import
sindunuragarp Mar 19, 2017
34f688b
Reconfigured line to comply with pep8 length
sindunuragarp Mar 20, 2017
03bacb8
Removed additional pep8 e501 error caused by mtransforms
sindunuragarp Mar 21, 2017
465a453
STY: pep8 cleanup
tacaswell Mar 10, 2017
6e451f1
MNT: explicitly pass in file handle to print_figure_impl
tacaswell Mar 10, 2017
710b509
FIX: always remove the temporary file in eps print_figure
tacaswell Mar 10, 2017
9f53b14
STY: pep8 clean up
tacaswell Mar 10, 2017
b9ff429
FIX: always remove the temporary file in eps print_figure_tex
tacaswell Mar 10, 2017
c3d012a
Revert "numpydocstring added"
kahnchana Mar 22, 2017
d12a3cd
Docstring to Numpydoc
kahnchana Mar 22, 2017
0b4909a
FIX small nitpicks
kahnchana Mar 22, 2017
8e54067
Merge branch 'docstring' of https://github.com/kahnchana/matplotlib i…
kahnchana Mar 22, 2017
a0c7bd8
Made style changes and edits suggested
kahnchana Mar 22, 2017
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
Prev Previous commit
Next Next commit
Revert "numpydocstring added"
This reverts commit ea9250d.
  • Loading branch information
kahnchana committed Mar 22, 2017
commit 492b0ac6f498caf6684aafaad8d349e776974ad6
162 changes: 80 additions & 82 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
'markeredgecolor': ['mec'],
'markeredgewidth': ['mew'],
'markersize': ['ms'],
}
}


def _plot_args_replacer(args, data):
Expand Down Expand Up @@ -1063,7 +1063,7 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',

verts = [((thisx, thisymin), (thisx, thisymax))
for thisx, thisymin, thisymax in zip(x, ymin, ymax)]
# print 'creating line collection'
#print 'creating line collection'
lines = mcoll.LineCollection(verts, colors=colors,
linestyles=linestyles, label=label)
self.add_collection(lines, autolim=False)
Expand All @@ -1082,9 +1082,9 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
return lines

@_preprocess_data(replace_names=["positions", "lineoffsets",
"linelengths", "linewidths",
"colors", "linestyles"],
label_namer=None)
"linelengths", "linewidths",
"colors", "linestyles"],
label_namer=None)
@docstring.dedent_interpd
def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
linelengths=1, linewidths=None, colors=None,
Expand Down Expand Up @@ -1226,7 +1226,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
colls = []
for position, lineoffset, linelength, linewidth, color, linestyle in \
zip(positions, lineoffsets, linelengths, linewidths,
colors, linestyles):
colors, linestyles):
coll = mcoll.EventCollection(position,
orientation=orientation,
lineoffset=lineoffset,
Expand Down Expand Up @@ -1263,8 +1263,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
# ### Basic plotting
# The label_naming happens in `matplotlib.axes._base._plot_args`
@_preprocess_data(replace_names=["x", "y"],
positional_parameter_names=_plot_args_replacer,
label_namer=None)
positional_parameter_names=_plot_args_replacer,
label_namer=None)
@docstring.dedent_interpd
def plot(self, *args, **kwargs):
"""
Expand Down Expand Up @@ -1857,10 +1857,10 @@ def step(self, x, y, *args, **kwargs):
return self.plot(x, y, *args, **kwargs)

@_preprocess_data(replace_names=["left", "height", "width", "bottom",
"color", "edgecolor", "linewidth",
"tick_label", "xerr", "yerr",
"ecolor"],
label_namer=None)
"color", "edgecolor", "linewidth",
"tick_label", "xerr", "yerr",
"ecolor"],
label_namer=None)
@docstring.dedent_interpd
def bar(self, left, height, width=0.8, bottom=None, **kwargs):
"""
Expand Down Expand Up @@ -2469,108 +2469,105 @@ 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,
wedgeprops=None, textprops=None, center=(0, 0),
frame=False, rotatelabels=False):
r"""Plot a pie chart.
r"""
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.

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

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

colors: None or array
*colors*: [ *None* | color sequence ]
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 or list
*labels*: [ *None* | len(x) sequence of strings ]
A sequence of strings providing the labels for each wedge

autopct: None or string or function
*autopct*: [ *None* | format string | format function ]
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: float
*pctdistance*: scalar
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.

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

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

startangle: None or Offset angle
*startangle*: [ *None* | Offset angle ]
If not *None*, rotates the start of the pie chart by *angle*
degrees counterclockwise from the x-axis.

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

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

wedgeprops: None or dict
*wedgeprops*: [ *None* | dict of key value pairs ]
Dict of arguments passed to the wedge objects making the pie.
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`.

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

center: list of int
Center position of the chart. Takes value (0,0) or is a sequence
of 2 scalars.
*center*: [ (0,0) | sequence of 2 scalars ]
Center position of the chart.

frame: bool
Plot axes frame with the chart if true.
*frame*: [ *False* | *True* ]
Plot axes frame with the chart.

rotatelabels: bool
Rotate each label to the angle of the corresponding slice if true.
*rotatelabels*: [ *False* | *True* ]
Rotate each label to the angle of the corresponding slice.

Returns
-------
patches: list
A sequence of :class:`matplotlib.patches.Wedge` instances
The pie chart will probably look best if the figure and axes are
square, or the Axes aspect is equal. e.g.::

texts: list
A is a list of the label :class:`matplotlib.text.Text` instances.
figure(figsize=(8,8))
ax = axes([0.1, 0.1, 0.8, 0.8])

autotexts: list
A is a list of :class:`~matplotlib.text.Text` instances for the
numeric labels. Is returned only is if parameter *autopct* is
not *None*. If *autopct* is *None*, the tuple returned
is (patches, texts).
or::

Examples
--------
The pie chart will probably look best if the figure and axes are
square, or the Axes aspect is equal.
axes(aspect=1)

Return value:
If *autopct* is *None*, return the tuple (*patches*, *texts*):

>>> figure(figsize=(8,8))
>>> ax = axes([0.1, 0.1, 0.8, 0.8])
- *patches* is a sequence of
:class:`matplotlib.patches.Wedge` instances

>>> axes(aspect=1)
- *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 @@ -2626,9 +2623,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 @@ -2685,9 +2682,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 All @@ -2697,7 +2694,7 @@ def get_next_color():
return slices, texts, autotexts

@_preprocess_data(replace_names=["x", "y", "xerr", "yerr"],
label_namer="y")
label_namer="y")
@docstring.dedent_interpd
def errorbar(self, x, y, yerr=None, xerr=None,
fmt='', ecolor=None, elinewidth=None, capsize=None,
Expand Down Expand Up @@ -3308,8 +3305,7 @@ def _update_dict(dictionary, rc_name, properties):
dictionary = dict()
for prop_dict in properties:
dictionary.setdefault(prop_dict,
rcParams[rc_str.format(rc_name,
prop_dict)])
rcParams[rc_str.format(rc_name, prop_dict)])
return dictionary

# Common property dictionnaries loading from rc
Expand All @@ -3319,7 +3315,7 @@ def _update_dict(dictionary, rc_name, properties):

boxprops = _update_dict(boxprops, 'boxprops', default_props)
whiskerprops = _update_dict(whiskerprops, 'whiskerprops',
default_props)
default_props)
capprops = _update_dict(capprops, 'capprops', default_props)
medianprops = _update_dict(medianprops, 'medianprops', default_props)
meanprops = _update_dict(meanprops, 'meanprops', default_props)
Expand Down Expand Up @@ -3811,9 +3807,9 @@ def dopatch(xs, ys, **kwargs):
medians=medians, fliers=fliers, means=means)

@_preprocess_data(replace_names=["x", "y", "s", "linewidths",
"edgecolors", "c", 'facecolor',
'facecolors', 'color'],
label_namer="y")
"edgecolors", "c", 'facecolor',
'facecolors', 'color'],
label_namer="y")
def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None,
verts=None, edgecolors=None,
Expand Down Expand Up @@ -4617,7 +4613,7 @@ def stackplot(self, x, *args, **kwargs):
stackplot.__doc__ = mstack.stackplot.__doc__

@_preprocess_data(replace_names=["x", "y", "u", "v", "start_points"],
label_namer=None)
label_namer=None)
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
minlength=0.1, transform=None, zorder=None,
Expand Down Expand Up @@ -4717,7 +4713,7 @@ def fill(self, *args, **kwargs):
return patches

@_preprocess_data(replace_names=["x", "y1", "y2", "where"],
label_namer=None)
label_namer=None)
@docstring.dedent_interpd
def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
step=None,
Expand Down Expand Up @@ -4886,7 +4882,7 @@ def get_interp_point(ind):
return collection

@_preprocess_data(replace_names=["y", "x1", "x2", "where"],
label_namer=None)
label_namer=None)
@docstring.dedent_interpd
def fill_betweenx(self, y, x1, x2=0, where=None,
step=None, interpolate=False, **kwargs):
Expand Down Expand Up @@ -5185,7 +5181,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
if im.get_clip_path() is None:
# image does not already have clipping set, clip to axes patch
im.set_clip_path(self.patch)
# if norm is None and shape is None:
#if norm is None and shape is None:
# im.set_clim(vmin, vmax)
if vmin is not None or vmax is not None:
im.set_clim(vmin, vmax)
Expand Down Expand Up @@ -5245,7 +5241,7 @@ def _pcolorargs(funcname, *args, **kw):
if X.shape != Y.shape:
raise TypeError(
'Incompatible X, Y inputs to %s; see help(%s)' % (
funcname, funcname))
funcname, funcname))
if allmatch:
if not (Nx == numCols and Ny == numRows):
raise TypeError('Dimensions of C %s are incompatible with'
Expand Down Expand Up @@ -5497,7 +5493,7 @@ def pcolor(self, *args, **kwargs):
# Transform from native to data coordinates?
t = collection._transform
if (not isinstance(t, mtransforms.Transform) and
hasattr(t, '_as_mpl_transform')):
hasattr(t, '_as_mpl_transform')):
t = t._as_mpl_transform(self.axes)

if t and any(t.contains_branch_seperately(self.transData)):
Expand Down Expand Up @@ -5649,7 +5645,7 @@ def pcolormesh(self, *args, **kwargs):
# Transform from native to data coordinates?
t = collection._transform
if (not isinstance(t, mtransforms.Transform) and
hasattr(t, '_as_mpl_transform')):
hasattr(t, '_as_mpl_transform')):
t = t._as_mpl_transform(self.axes)

if t and any(t.contains_branch_seperately(self.transData)):
Expand Down Expand Up @@ -7348,7 +7344,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
nr, nc = Z.shape
extent = [-0.5, nc - 0.5, nr - 0.5, -0.5]
ret = self.imshow(mask, interpolation='nearest', aspect=aspect,
extent=extent, origin=origin, **kwargs)
extent=extent, origin=origin, **kwargs)
else:
if hasattr(Z, 'tocoo'):
c = Z.tocoo()
Expand All @@ -7368,8 +7364,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
if markersize is None:
markersize = 10
marks = mlines.Line2D(x, y, linestyle='None',
marker=marker, markersize=markersize,
**kwargs)
marker=marker, markersize=markersize, **kwargs)
self.add_line(marks)
nr, nc = Z.shape
self.set_xlim(xmin=-0.5, xmax=nc - 0.5)
Expand All @@ -7380,9 +7375,11 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
self.xaxis.tick_top()
self.xaxis.set_ticks_position('both')
self.xaxis.set_major_locator(mticker.MaxNLocator(nbins=9,
steps=[1, 2, 5, 10], integer=True))
steps=[1, 2, 5, 10],
integer=True))
self.yaxis.set_major_locator(mticker.MaxNLocator(nbins=9,
steps=[1, 2, 5, 10], integer=True))
steps=[1, 2, 5, 10],
integer=True))
return ret

def matshow(self, Z, **kwargs):
Expand Down Expand Up @@ -7427,10 +7424,11 @@ def matshow(self, Z, **kwargs):
self.xaxis.tick_top()
self.xaxis.set_ticks_position('both')
self.xaxis.set_major_locator(mticker.MaxNLocator(nbins=9,
steps=[1, 2, 5, 10], integer=True))
steps=[1, 2, 5, 10],
integer=True))
self.yaxis.set_major_locator(mticker.MaxNLocator(nbins=9,
steps=[1, 2, 5, 10],
integer=True))
steps=[1, 2, 5, 10],
integer=True))
return im

@_preprocess_data(replace_names=["dataset"], label_namer=None)
Expand Down