I want to plot the frequency composition of a sampled signal data versus time by using surf or any 3D plot. Normally time resolution of FFT is zero so I want to use wavelet transform where I want to see frequency versus coefficients wrt time.

As an example signal I chose a chirp signal below along with the code:

enter image description here

import pywt
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import chirp

fs = 1024
sampling_period = 1 / fs
t = np.linspace(0, 10, 2 * fs)
w = chirp(t, f0=10, f1=1, t1=10, method='linear')
plt.plot(t, w)
plt.title("Linear Chirp, f(0)=6, f(10)=1")
plt.xlabel('t (sec)')

# Calculate continuous wavelet transform
coef, freqs = pywt.cwt(w, np.arange(1, 2049), 'morl',

But after the last line I got stuck. I couldn't relate the parameters in a way to obtain a surface plot for coef freqs and t. How to achieve that or at least a meaningful wavelet plot?

I want to obtain a plot similar to this one:

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.