From 5c1fb3359279c53c3067e2a5c638b739104f5078 Mon Sep 17 00:00:00 2001 From: Omer Sayli <39605236+omersayli@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:04:40 +0300 Subject: [PATCH] DOC: improve figures in `demo/wp_scalogram.py` (#769) In the second plot, updated Fs to 512; `ax2.specgram(data, NFFT=64, noverlap=32, Fs=512, cmap=cmap, interpolation='bilinear')` again in the second plot, added aspect='auto', and did corrections to the time (x axis) and y axis (scale) with `extent=[0, 1, 1, values.shape[0]]` ax3.imshow(values, origin='lower', extent=[0, 1, 1, values.shape[0]], interpolation='nearest', aspect='auto') Figure 2-subplot 2 in this version is compatible with Figure 1-subplot 2 y-axis labels for the wavelet packet names --- demo/wp_scalogram.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/demo/wp_scalogram.py b/demo/wp_scalogram.py index 5df9afede..31be199a1 100644 --- a/demo/wp_scalogram.py +++ b/demo/wp_scalogram.py @@ -38,12 +38,13 @@ # Show spectrogram and wavelet packet coefficients fig2 = plt.figure() ax2 = fig2.add_subplot(211) -ax2.specgram(data, NFFT=64, noverlap=32, Fs=2, cmap=cmap, +ax2.specgram(data, NFFT=64, noverlap=32, Fs=512, cmap=cmap, interpolation='bilinear') ax2.set_title("Spectrogram of signal") ax3 = fig2.add_subplot(212) -ax3.imshow(values, origin='upper', extent=[-1, 1, -1, 1], - interpolation='nearest') +ax3.imshow(values, origin='lower', extent=[0, 1, 0, len(values)], + interpolation='nearest', aspect='auto') +ax3.set_yticks(np.arange(0.5, len(labels) + 0.5), labels) ax3.set_title("Wavelet packet coefficients")