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

Skip to content

Commit 3896b98

Browse files
committed
Minor cleanup of acorr/xcoor docs
1 parent a4d82fe commit 3896b98

File tree

3 files changed

+68
-35
lines changed

3 files changed

+68
-35
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ per-file-ignores =
153153
examples/lines_bars_and_markers/stem_plot.py: E402
154154
examples/lines_bars_and_markers/step_demo.py: E402
155155
examples/lines_bars_and_markers/timeline.py: E402
156+
examples/lines_bars_and_markers/xcorr_acorr_demo.py: E402
156157
examples/misc/agg_buffer.py: E402
157158
examples/misc/anchored_artists.py: E501
158159
examples/misc/contour_manual.py: E501

examples/lines_bars_and_markers/xcorr_acorr_demo.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Cross- and Auto-Correlation Demo
44
================================
55
6-
Example use of cross-correlation (`xcorr`) and auto-correlation (`acorr`)
7-
plots.
6+
Example use of cross-correlation (`~.Axes.xcorr`) and auto-correlation
7+
(`~.Axes.acorr`) plots.
88
"""
99
import matplotlib.pyplot as plt
1010
import numpy as np
@@ -18,10 +18,24 @@
1818
fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
1919
ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
2020
ax1.grid(True)
21-
ax1.axhline(0, color='black', lw=2)
2221

2322
ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
2423
ax2.grid(True)
25-
ax2.axhline(0, color='black', lw=2)
2624

2725
plt.show()
26+
27+
#############################################################################
28+
#
29+
# ------------
30+
#
31+
# References
32+
# """"""""""
33+
#
34+
# The use of the following functions, methods, classes and modules is shown
35+
# in this example:
36+
37+
import matplotlib
38+
matplotlib.axes.Axes.acorr
39+
matplotlib.axes.Axes.xcorr
40+
matplotlib.pyplot.acorr
41+
matplotlib.pyplot.xcorr

lib/matplotlib/axes/_axes.py

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,19 +1905,25 @@ def acorr(self, x, **kwargs):
19051905
19061906
Parameters
19071907
----------
1908-
1909-
x : sequence of scalar
1908+
x : array-like
19101909
19111910
detrend : callable, optional, default: `mlab.detrend_none`
1912-
*x* is detrended by the *detrend* callable. Default is no
1913-
normalization.
1911+
*x* is detrended by the *detrend* callable. This must be a
1912+
function ``x = detrend(x)`` accepting and returning an
1913+
`numpy.array`. Default is no normalization.
19141914
19151915
normed : bool, optional, default: True
19161916
If ``True``, input vectors are normalised to unit length.
19171917
19181918
usevlines : bool, optional, default: True
1919-
If ``True``, `Axes.vlines` is used to plot the vertical lines from
1920-
the origin to the acorr. Otherwise, `Axes.plot` is used.
1919+
Determines the plot style.
1920+
1921+
If ``True``, vertical lines are plotted from 0 to the acorr value
1922+
using `Axes.vlines`. Additionally, a horizontal line is plotted
1923+
at y=0 using `Axes.axhline`.
1924+
1925+
If ``False``, makers are plotted at the acorr values using
1926+
`Axes.plot`.
19211927
19221928
maxlags : int, optional, default: 10
19231929
Number of lags to show. If ``None``, will return all
@@ -1926,24 +1932,27 @@ def acorr(self, x, **kwargs):
19261932
Returns
19271933
-------
19281934
lags : array (length ``2*maxlags+1``)
1929-
lag vector.
1935+
The lag vector.
19301936
c : array (length ``2*maxlags+1``)
1931-
auto correlation vector.
1937+
The auto correlation vector.
19321938
line : `.LineCollection` or `.Line2D`
1933-
`.Artist` added to the axes of the correlation.
1939+
`.Artist` added to the axes of the correlation:
19341940
1935-
`.LineCollection` if *usevlines* is True
1936-
`.Line2D` if *usevlines* is False
1941+
- `.LineCollection` if *usevlines* is True.
1942+
- `.Line2D` if *usevlines* is False.
19371943
b : `.Line2D` or None
19381944
Horizontal line at 0 if *usevlines* is True
1939-
None *usevlines* is False
1945+
None *usevlines* is False.
19401946
19411947
Other Parameters
19421948
----------------
1943-
linestyle : `.Line2D` property, optional, default: None
1944-
Only used if usevlines is ``False``.
1949+
linestyle : `.Line2D` property, optional
1950+
The linestyle for plotting the data points.
1951+
Only used if *usevlines* is ``False``.
19451952
19461953
marker : str, optional, default: 'o'
1954+
The marker for plotting the data points.
1955+
Only used if *usevlines* is ``False``.
19471956
19481957
Notes
19491958
-----
@@ -1964,47 +1973,56 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
19641973
19651974
Parameters
19661975
----------
1967-
x : sequence of scalars of length n
1976+
x : array-like of length n
19681977
1969-
y : sequence of scalars of length n
1978+
y : array-like of length n
19701979
19711980
detrend : callable, optional, default: `mlab.detrend_none`
1972-
*x* is detrended by the *detrend* callable. Default is no
1973-
normalization.
1981+
*x* and *y* are detrended by the *detrend* callable. This must be a
1982+
function ``x = detrend(x)`` accepting and returning an
1983+
`numpy.array`. Default is no normalization.
19741984
19751985
normed : bool, optional, default: True
19761986
If ``True``, input vectors are normalised to unit length.
19771987
19781988
usevlines : bool, optional, default: True
1979-
If ``True``, `Axes.vlines` is used to plot the vertical lines from
1980-
the origin to the acorr. Otherwise, `Axes.plot` is used.
1989+
Determines the plot style.
19811990
1982-
maxlags : int, optional
1991+
If ``True``, vertical lines are plotted from 0 to the xcorr value
1992+
using `Axes.vlines`. Additionally, a horizontal line is plotted
1993+
at y=0 using `Axes.axhline`.
1994+
1995+
If ``False``, makers are plotted at the xcorr values using
1996+
`Axes.plot`.
1997+
1998+
maxlags : int, optional, default: 10
19831999
Number of lags to show. If None, will return all ``2 * len(x) - 1``
1984-
lags. Default is 10.
2000+
lags.
19852001
19862002
Returns
19872003
-------
19882004
lags : array (length ``2*maxlags+1``)
1989-
lag vector.
2005+
The lag vector.
19902006
c : array (length ``2*maxlags+1``)
1991-
auto correlation vector.
2007+
The auto correlation vector.
19922008
line : `.LineCollection` or `.Line2D`
1993-
`.Artist` added to the axes of the correlation
2009+
`.Artist` added to the axes of the correlation:
19942010
1995-
`.LineCollection` if *usevlines* is True
1996-
`.Line2D` if *usevlines* is False
2011+
- `.LineCollection` if *usevlines* is True.
2012+
- `.Line2D` if *usevlines* is False.
19972013
b : `.Line2D` or None
19982014
Horizontal line at 0 if *usevlines* is True
1999-
None *usevlines* is False
2015+
None *usevlines* is False.
20002016
20012017
Other Parameters
20022018
----------------
20032019
linestyle : `.Line2D` property, optional
2004-
Only used if usevlines is ``False``.
2020+
The linestyle for plotting the data points.
2021+
Only used if *usevlines* is ``False``.
20052022
2006-
marker : string, optional
2007-
Default is 'o'.
2023+
marker : str, optional, default: 'o'
2024+
The marker for plotting the data points.
2025+
Only used if *usevlines* is ``False``.
20082026
20092027
Notes
20102028
-----

0 commit comments

Comments
 (0)