Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43bf56e

Browse files
committed
Merge pull request #2204 from NelleV/MEP10_acorr
MEP10 acorr methods
2 parents 64cc341 + e015a0c commit 43bf56e

File tree

1 file changed

+79
-87
lines changed

1 file changed

+79
-87
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 79 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ def set_title(self, label, fontdict=None, loc="center", **kwargs):
129129
default = {
130130
'fontsize': rcParams['axes.titlesize'],
131131
'verticalalignment': 'baseline',
132-
'horizontalalignment': loc.lower()
133-
}
132+
'horizontalalignment': loc.lower()}
134133
title.set_text(label)
135134
title.update(default)
136135
if fontdict is not None:
@@ -455,7 +454,7 @@ def text(self, x, y, s, fontdict=None,
455454
"""
456455
Add text to the axes.
457456
458-
Add text in string *s* to axis at location *x*, *y*, data
457+
Add text in string `s` to axis at location `x`, `y`, data
459458
coordinates.
460459
461460
Parameters
@@ -496,7 +495,7 @@ def text(self, x, y, s, fontdict=None,
496495
... transform=ax.transAxes)
497496
498497
You can put a rectangular box around the text instance (e.g., to
499-
set a background color) by using the keyword *bbox*. *bbox* is
498+
set a background color) by using the keyword `bbox`. `bbox` is
500499
a dictionary of `~matplotlib.patches.Rectangle`
501500
properties. For example::
502501
@@ -506,8 +505,7 @@ def text(self, x, y, s, fontdict=None,
506505
'verticalalignment': 'baseline',
507506
'horizontalalignment': 'left',
508507
'transform': self.transData,
509-
'clip_on': False
510-
}
508+
'clip_on': False}
511509

512510
# At some point if we feel confident that TextWithDash
513511
# is robust as a drop-in replacement for Text and that
@@ -803,15 +801,13 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
803801

804802
@docstring.dedent
805803
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
806-
label='', **kwargs):
804+
label='', **kwargs):
807805
"""
808-
Plot horizontal lines.
809-
810806
Plot horizontal lines at each `y` from `xmin` to `xmax`.
811807
812808
Parameters
813809
----------
814-
y : scalar or 1D array_like
810+
y : scalar or sequence of scalar
815811
y-indexes where to plot the lines.
816812
817813
xmin, xmax : scalar or 1D array_like
@@ -1531,63 +1527,61 @@ def semilogy(self, *args, **kwargs):
15311527
@docstring.dedent_interpd
15321528
def acorr(self, x, **kwargs):
15331529
"""
1534-
Plot the autocorrelation of *x*.
1535-
1536-
Call signature::
1537-
1538-
acorr(x, normed=True, detrend=mlab.detrend_none, usevlines=True,
1539-
maxlags=10, **kwargs)
1530+
Plot the autocorrelation of `x`.
15401531
1541-
If *normed* = *True*, normalize the data by the autocorrelation at
1542-
0-th lag. *x* is detrended by the *detrend* callable (default no
1543-
normalization).
1544-
1545-
Data are plotted as ``plot(lags, c, **kwargs)``
1546-
1547-
Return value is a tuple (*lags*, *c*, *line*) where:
1532+
Parameters
1533+
----------
15481534
1549-
- *lags* are a length 2*maxlags+1 lag vector
1535+
x : sequence of scalar
15501536
1551-
- *c* is the 2*maxlags+1 auto correlation vector
1537+
hold : boolean, optional, default: True
15521538
1553-
- *line* is a :class:`~matplotlib.lines.Line2D` instance
1554-
returned by :meth:`plot`
1539+
detrend : callable, optional, default: `mlab.detrend_none`
1540+
x is detrended by the `detrend` callable. Default is no
1541+
normalization.
15551542
1556-
The default *linestyle* is None and the default *marker* is
1557-
``'o'``, though these can be overridden with keyword args.
1558-
The cross correlation is performed with
1559-
:func:`numpy.correlate` with *mode* = 2.
1543+
normed : boolean, optional, default: True
1544+
if True, normalize the data by the autocorrelation at the 0-th
1545+
lag.
15601546
1561-
If *usevlines* is *True*, :meth:`~matplotlib.axes.Axes.vlines`
1562-
rather than :meth:`~matplotlib.axes.Axes.plot` is used to draw
1563-
vertical lines from the origin to the acorr. Otherwise, the
1564-
plot style is determined by the kwargs, which are
1565-
:class:`~matplotlib.lines.Line2D` properties.
1547+
usevlines : boolean, optional, default: True
1548+
if True, Axes.vlines is used to plot the vertical lines from the
1549+
origin to the acorr. Otherwise, Axes.plot is used.
15661550
1567-
*maxlags* is a positive integer detailing the number of lags
1568-
to show. The default value of *None* will return all
1569-
``(2*len(x)-1)`` lags.
1551+
maxlags : integer, optional, default: 10
1552+
number of lags to show. If None, will return all 2 * len(x) - 1
1553+
lags.
15701554
1571-
The return value is a tuple (*lags*, *c*, *linecol*, *b*)
1572-
where
1555+
Returns
1556+
-------
1557+
(lags, c, line, b) : where:
15731558
1574-
- *linecol* is the
1575-
:class:`~matplotlib.collections.LineCollection`
1559+
- `lags` are a length 2`maxlags+1 lag vector.
1560+
- `c` is the 2`maxlags+1 auto correlation vectorI
1561+
- `line` is a `~matplotlib.lines.Line2D` instance returned by
1562+
`plot`.
1563+
- `b` is the x-axis.
15761564
1577-
- *b* is the *x*-axis.
1565+
Other parameters
1566+
-----------------
1567+
linestyle : `~matplotlib.lines.Line2D` prop, optional, default: None
1568+
Only used if usevlines is False.
15781569
1579-
.. seealso::
1570+
marker : string, optional, default: 'o'
15801571
1581-
:meth:`~matplotlib.axes.Axes.plot` or
1582-
:meth:`~matplotlib.axes.Axes.vlines`
1583-
For documentation on valid kwargs.
1572+
Notes
1573+
-----
1574+
The cross correlation is performed with :func:`numpy.correlate` with
1575+
`mode` = 2.
15841576
1585-
**Example:**
1577+
Examples
1578+
--------
15861579
1587-
:func:`~matplotlib.pyplot.xcorr` is top graph, and
1588-
:func:`~matplotlib.pyplot.acorr` is bottom graph.
1580+
`~matplotlib.pyplot.xcorr` is top graph, and
1581+
`~matplotlib.pyplot.acorr` is bottom graph.
15891582
15901583
.. plot:: mpl_examples/pylab_examples/xcorr_demo.py
1584+
15911585
"""
15921586
return self.xcorr(x, x, **kwargs)
15931587

@@ -1597,54 +1591,52 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
15971591
"""
15981592
Plot the cross correlation between *x* and *y*.
15991593
1600-
Call signature::
1601-
1602-
xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
1603-
usevlines=True, maxlags=10, **kwargs)
1604-
1605-
If *normed* = *True*, normalize the data by the cross
1606-
correlation at 0-th lag. *x* and y are detrended by the
1607-
*detrend* callable (default no normalization). *x* and *y*
1608-
must be equal length.
1609-
1610-
Data are plotted as ``plot(lags, c, **kwargs)``
1594+
Parameters
1595+
----------
16111596
1612-
Return value is a tuple (*lags*, *c*, *line*) where:
1597+
x : sequence of scalars of length n
16131598
1614-
- *lags* are a length ``2*maxlags+1`` lag vector
1599+
y : sequence of scalars of length n
16151600
1616-
- *c* is the ``2*maxlags+1`` auto correlation vector
1601+
hold : boolean, optional, default: True
16171602
1618-
- *line* is a :class:`~matplotlib.lines.Line2D` instance
1619-
returned by :func:`~matplotlib.pyplot.plot`.
1603+
detrend : callable, optional, default: `mlab.detrend_none`
1604+
x is detrended by the `detrend` callable. Default is no
1605+
normalization.
16201606
1621-
The default *linestyle* is *None* and the default *marker* is
1622-
'o', though these can be overridden with keyword args. The
1623-
cross correlation is performed with :func:`numpy.correlate`
1624-
with *mode* = 2.
1607+
normed : boolean, optional, default: True
1608+
if True, normalize the data by the autocorrelation at the 0-th
1609+
lag.
16251610
1626-
If *usevlines* is *True*:
1611+
usevlines : boolean, optional, default: True
1612+
if True, Axes.vlines is used to plot the vertical lines from the
1613+
origin to the acorr. Otherwise, Axes.plot is used.
16271614
1628-
:func:`~matplotlib.pyplot.vlines`
1629-
rather than :func:`~matplotlib.pyplot.plot` is used to draw
1630-
vertical lines from the origin to the xcorr. Otherwise the
1631-
plotstyle is determined by the kwargs, which are
1632-
:class:`~matplotlib.lines.Line2D` properties.
1615+
maxlags : integer, optional, default: 10
1616+
number of lags to show. If None, will return all 2 * len(x) - 1
1617+
lags.
16331618
1634-
The return value is a tuple (*lags*, *c*, *linecol*, *b*)
1635-
where *linecol* is the
1636-
:class:`matplotlib.collections.LineCollection` instance and
1637-
*b* is the *x*-axis.
1619+
Returns
1620+
-------
1621+
(lags, c, line, b) : where:
16381622
1639-
*maxlags* is a positive integer detailing the number of lags to show.
1640-
The default value of *None* will return all ``(2*len(x)-1)`` lags.
1623+
- `lags` are a length 2`maxlags+1 lag vector.
1624+
- `c` is the 2`maxlags+1 auto correlation vectorI
1625+
- `line` is a `~matplotlib.lines.Line2D` instance returned by
1626+
`plot`.
1627+
- `b` is the x-axis (none, if plot is used).
16411628
1642-
**Example:**
1629+
Other parameters
1630+
-----------------
1631+
linestyle : `~matplotlib.lines.Line2D` prop, optional, default: None
1632+
Only used if usevlines is False.
16431633
1644-
:func:`~matplotlib.pyplot.xcorr` is top graph, and
1645-
:func:`~matplotlib.pyplot.acorr` is bottom graph.
1634+
marker : string, optional, default: 'o'
16461635
1647-
.. plot:: mpl_examples/pylab_examples/xcorr_demo.py
1636+
Notes
1637+
-----
1638+
The cross correlation is performed with :func:`numpy.correlate` with
1639+
`mode` = 2.
16481640
"""
16491641

16501642
Nx = len(x)

0 commit comments

Comments
 (0)