X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions examples/lines_bars_and_markers/cohere_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
=====================================
Plotting the coherence of two signals
=====================================

An example showing how to plot the coherence of two signals.
"""
import numpy as np
import matplotlib.pyplot as plt

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

dt = 0.01
t = np.arange(0, 30, dt)
nse1 = np.random.randn(len(t)) # white noise 1
nse2 = np.random.randn(len(t)) # white noise 2

# Two signals with a coherent part at 10Hz and a random part
s1 = np.sin(2 * np.pi * 10 * t) + nse1
s2 = np.sin(2 * np.pi * 10 * t) + nse2

fig, axs = plt.subplots(2, 1)
axs[0].plot(t, s1, t, s2)
axs[0].set_xlim(0, 2)
axs[0].set_xlabel('time')
axs[0].set_ylabel('s1 and s2')
axs[0].grid(True)

cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt)
axs[1].set_ylabel('coherence')

fig.tight_layout()
plt.show()
37 changes: 0 additions & 37 deletions examples/pylab_examples/cohere_demo.py

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tests/backend_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

files['lines'] = [
'barh_demo.py',
'cohere_demo.py',
'fill_demo.py',
'fill_demo_features.py',
'line_demo_dash_control.py',
Expand Down Expand Up @@ -127,7 +128,6 @@
'barcode_demo.py',
'boxplot_demo.py',
'broken_barh.py',
'cohere_demo.py',
'color_by_yvalue.py',
'color_demo.py',
'colorbar_tick_labelling_demo.py',
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7082,7 +7082,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,

Examples
--------
.. plot:: mpl_examples/pylab_examples/cohere_demo.py
.. plot:: mpl_examples/lines_bars_and_markers/cohere_demo.py
"""
if not self._hold:
self.cla()
Expand Down
X Tutup