8000 Merge pull request #7968 from dstansby/cohere-demo-fix · matplotlib/matplotlib@e6e8468 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6e8468

Browse files
authored
Merge pull request #7968 from dstansby/cohere-demo-fix
[MRG+1] Fix cohere-demo
2 parents c15694b + f406d7d commit e6e8468

File tree

4 files changed

+36
-39
lines changed

4 files changed

+36
-39
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""
2+
=====================================
3+
Plotting the coherence of two signals
4+
=====================================
5+
6+
An example showing how to plot the coherence of two signals.
7+
"""
8+
import numpy as np
9+
import matplotlib.pyplot as plt
10+
11+
# Fixing random state for reproducibility
12+
np.random.seed(19680801)
13+
14+
dt = 0.01
15+
t = np.arange(0, 30, dt)
16+
nse1 = np.random.randn(len(t)) # white noise 1
17+
nse2 = np.random.randn(len(t)) # white noise 2
18+
19+
# Two signals with a coherent part at 10Hz and a random part
20+
s1 = np.sin(2 * np.pi * 10 * t) + nse1
21+
s2 = np.sin(2 * np.pi * 10 * t) + nse2
22+
23+
fig, axs = plt.subplots(2, 1)
24+
axs[0].plot(t, s1, t, s2)
25+
axs[0].set_xlim(0, 2)
26+
axs[0].set_xlabel('time')
27+
axs[0].set_ylabel('s1 and s2')
28+
axs[0].grid(True)
29+
30+
cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt)
31+
axs[1].set_ylabel('coherence')
32+
33+
fig.tight_layout()
34+
plt.show()

examples/pylab_examples/cohere_demo.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

examples/tests/backend_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252

5353
files['lines'] = [
5454
'barh_demo.py',
55+
'cohere_demo.py',
5556
'fill_demo.py',
5657
'fill_demo_features.py',
5758
'line_demo_dash_control.py',
@@ -127,7 +128,6 @@
127128
'barcode_demo.py',
128129
'boxplot_demo.py',
129130
'broken_barh.py',
130-
'cohere_demo.py',
131131
'color_by_yvalue.py',
132132
'color_demo.py',
133133
'colorbar_tick_labelling_demo.py',

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7086,7 +7086,7 @@ def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none,
70867086
70877087
Examples
70887088
--------
7089-
.. plot:: mpl_examples/pylab_examples/cohere_demo.py
7089+
.. plot:: mpl_examples/lines_bars_and_markers/cohere_demo.py
70907090
"""
70917091
if not self._hold:
70927092
self.cla()

0 commit comments

Comments
 (0)
0