| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Plot the set of 1D demo signals available in `pywt.data.demo_signal`.""" |
| 5 |
|
| 6 |
import numpy as np |
| 7 |
|
| 8 |
import matplotlib.pyplot as plt |
| 9 |
|
| 10 |
import pywt |
| 11 |
|
| 12 |
|
| 13 |
signals = pywt.data.demo_signal('list') |
| 14 |
|
| 15 |
subplots_per_fig = 5 |
| 16 |
signal_length = 1024 |
| 17 |
i_fig = 0 |
| 18 |
n_figures = int(np.ceil(len(signals)/subplots_per_fig)) |
| 19 |
for i_fig in range(n_figures): |
| 20 |
|
| 21 |
func_subset = signals[ |
| 22 |
i_fig * subplots_per_fig:(i_fig + 1) * subplots_per_fig] |
| 23 |
|
| 24 |
|
| 25 |
fig, axes = plt.subplots(subplots_per_fig, 1) |
| 26 |
axes = axes.ravel() |
| 27 |
for n, signal in enumerate(func_subset): |
| 28 |
if signal in ['Gabor', 'sineoneoverx']: |
| 29 |
|
| 30 |
x = pywt.data.demo_signal(signal) |
| 31 |
else: |
| 32 |
x = pywt.data.demo_signal(signal, signal_length) |
| 33 |
ax = axes[n] |
| 34 |
ax.plot(x.real) |
| 35 |
if signal == 'Gabor': |
| 36 |
|
| 37 |
ax.plot(x.imag) |
| 38 |
ax.legend(['Gabor (Re)', 'Gabor (Im)'], loc='upper left') |
| 39 |
else: |
| 40 |
ax.legend([signal, ], loc='upper left') |
| 41 |
|
| 42 |
for n in range(n + 1, len(axes)): |
| 43 |
axes[n].set_axis_off() |
| 44 |
plt.show() |