Version 3.1.2
matplotlib

Cross- and Auto-Correlation Demo

Example use of cross-correlation (xcorr) and auto-correlation (acorr) plots.

================================
Cross- and Auto-Correlation Demo
================================

Example use of cross-correlation (`~.Axes.xcorr`) and auto-correlation
(`~.Axes.acorr`) plots.
"""
import matplotlib.pyplot as plt
import numpy as np


# Fixing random state for reproducibility
np.random.seed(19680801)


x, y = np.random.randn(2, 100)
fig, [ax1, ax2] = plt.subplots(2, 1, sharex=True)
ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True, lw=2)
ax1.grid(True)

ax2.acorr(x, usevlines=True, normed=True, maxlags=50, lw=2)
ax2.grid(True)

plt.show()
Traceback (most recent call last):
  File "/build/matplotlib-mO9dyQ/matplotlib-3.1.2/examples/lines_bars_and_markers/xcorr_acorr_demo.py", line 1
    ================================
    ^
SyntaxError: invalid syntax

References

The use of the following functions, methods, classes and modules is shown in this example:

import matplotlib
matplotlib.axes.Axes.acorr
matplotlib.axes.Axes.xcorr
matplotlib.pyplot.acorr
matplotlib.pyplot.xcorr

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery