Skip to content

Commit

Permalink
Merge pull request matplotlib#18463 from anntzer/defaults
Browse files Browse the repository at this point in the history
Improve formatting of defaults in docstrings.
  • Loading branch information
timhoffm authored Sep 13, 2020
2 parents 1b1afe1 + ae1ce09 commit 7fb5b6c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 33 deletions.
5 changes: 2 additions & 3 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,9 @@ def setup(self, fig, outfile, dpi=None, frame_prefix=None,
The figure to grab the rendered frames from.
outfile : str
The filename of the resulting movie file.
dpi : float, optional
dpi : float, default: ``fig.dpi``
The dpi of the output file. This, with the figure size,
controls the size in pixels of the resulting movie file.
Default is ``fig.dpi``.
frame_prefix : str, optional
The filename prefix to use for temporary files. If None (the
default), files are written to a temporary directory which is
Expand Down Expand Up @@ -1006,7 +1005,7 @@ class to use, such as 'ffmpeg'.
encoder. The default, None, means to use
:rc:`animation.[name-of-encoder]_args` for the builtin writers.
metadata : Dict[str, str], default {}
metadata : Dict[str, str], default: {}
Dictionary of keys and values for metadata to include in
the output file. Some keys that may be of use include:
title, artist, genre, subject, copyright, srcform, comment.
Expand Down
5 changes: 2 additions & 3 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7393,9 +7393,8 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
spectrum. 'angle' returns the phase spectrum without unwrapping.
'phase' returns the phase spectrum with unwrapping.
noverlap : int
The number of points of overlap between blocks. The
default value is 128.
noverlap : int, default: 128
The number of points of overlap between blocks.
scale : {'default', 'linear', 'dB'}
The scaling of the values in the *spec*. 'linear' is no scaling.
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,14 @@ def to_filehandle(fname, flag='r', return_opened=False, encoding=None):
fname : str or path-like or file-like
If `str` or `os.PathLike`, the file is opened using the flags specified
by *flag* and *encoding*. If a file-like object, it is passed through.
flag : str, default 'r'
flag : str, default: 'r'
Passed as the *mode* argument to `open` when *fname* is `str` or
`os.PathLike`; ignored if *fname* is file-like.
return_opened : bool, default False
return_opened : bool, default: False
If True, return both the file object and a boolean indicating whether
this was a new file (that the caller needs to close). If False, return
only the new file.
encoding : str or None, default None
encoding : str or None, default: None
Passed as the *mode* argument to `open` when *fname* is `str` or
`os.PathLike`; ignored if *fname* is file-like.
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ def legend_elements(self, prop="colors", num="auto",
the collection. If "sizes", the legend will show the different
sizes. To set both, use *kwargs* to directly edit the `.Line2D`
properties.
num : int, None, "auto" (default), array-like, or `~.ticker.Locator`,
num : int, None, "auto" (default), array-like, or `~.ticker.Locator`
Target number of elements to create.
If None, use all unique elements of the mappable array. If an
integer, target to use *num* elements in the normed range.
Expand All @@ -1028,7 +1028,7 @@ def legend_elements(self, prop="colors", num="auto",
The format or formatter to use for the labels. If a string must be
a valid input for a `~.StrMethodFormatter`. If None (the default),
use a `~.ScalarFormatter`.
func : function, default *lambda x: x*
func : function, default: ``lambda x: x``
Function to calculate the labels. Often the size (or color)
argument to `~.Axes.scatter` will have been pre-processed by the
user using a function ``s = f(x)`` to make the markers visible;
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ def num2date(x, tz=None):
Number of days (fraction part represents hours, minutes, seconds)
since the epoch. See `.get_epoch` for the
epoch, which can be changed by :rc:`date.epoch` or `.set_epoch`.
tz : str, optional
Timezone of *x* (defaults to :rc:`timezone`).
tz : str, default: :rc:`timezone`
Timezone of *x*.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,10 @@ def suptitle(self, t, **kwargs):
t : str
The title text.
x : float, default 0.5
x : float, default: 0.5
The x location of the text in figure coordinates.
y : float, default 0.98
y : float, default: 0.98
The y location of the text in figure coordinates.
horizontalalignment, ha : {'center', 'left', right'}, default: 'center'
Expand Down
24 changes: 8 additions & 16 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,10 @@ def stride_windows(x, n, noverlap=None, axis=0):
----------
x : 1D array or sequence
Array or sequence containing the data.
n : int
The number of data points in each window.
noverlap : int
noverlap : int, default: 0 (no overlap)
The overlap between adjacent windows.
Default is 0 (no overlap)
axis : int
The axis along which the windows will run.
Expand Down Expand Up @@ -629,7 +625,7 @@ def _single_spectrum_helper(
most efficient. This should *NOT* be used to get zero padding, or the
scaling of the result will be incorrect; use *pad_to* for this instead.
detrend : {'none', 'mean', 'linear'} or callable, default 'none'
detrend : {'none', 'mean', 'linear'} or callable, default: 'none'
The function applied to each segment before fft-ing, designed to remove
the mean or linear trend. Unlike in MATLAB, where the *detrend* parameter
is a vector, in Matplotlib is it a function. The :mod:`~matplotlib.mlab`
Expand Down Expand Up @@ -669,9 +665,8 @@ def psd(x, NFFT=None, Fs=None, detrend=None, window=None,
%(PSD)s
noverlap : int
noverlap : int, default: 0 (no overlap)
The number of points of overlap between segments.
The default value is 0 (no overlap).
Returns
-------
Expand Down Expand Up @@ -729,9 +724,8 @@ def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None,
%(PSD)s
noverlap : int
noverlap : int, default: 0 (no overlap)
The number of points of overlap between segments.
The default value is 0 (no overlap).
Returns
-------
Expand Down Expand Up @@ -845,9 +839,8 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
%(PSD)s
noverlap : int, optional
The number of points of overlap between blocks. The default
value is 128.
noverlap : int, default: 128
The number of points of overlap between blocks.
mode : str, default: 'psd'
What sort of spectrum to use:
'psd'
Expand Down Expand Up @@ -928,9 +921,8 @@ def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning,
%(PSD)s
noverlap : int
The number of points of overlap between blocks. The default value
is 0 (no overlap).
noverlap : int, default: 0 (no overlap)
The number of points of overlap between segments.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def __init__(self, *args, zs=0, zdir='z', depthshade=True, **kwargs):
:class:`~matplotlib.collections.PatchCollection`. In addition,
keywords *zs=0* and *zdir='z'* are available.
Also, the keyword argument "depthshade" is available to
Also, the keyword argument *depthshade* is available to
indicate whether or not to shade the patches in order to
give the appearance of depth (default is *True*).
This is typically desired in scatter plots.
Expand Down Expand Up @@ -460,7 +460,7 @@ def __init__(self, *args, zs=0, zdir='z', depthshade=True, **kwargs):
:class:`~matplotlib.collections.PathCollection`. In addition,
keywords *zs=0* and *zdir='z'* are available.
Also, the keyword argument "depthshade" is available to
Also, the keyword argument *depthshade* is available to
indicate whether or not to shade the patches in order to
give the appearance of depth (default is *True*).
This is typically desired in scatter plots.
Expand Down

0 comments on commit 7fb5b6c

Please sign in to comment.