How do you obtain a connected (staircase looking) representation of the scaling and wavelet coefficients instead of the unconnected result in the image below? It looks nicer in Matlab than in Python?
import pywt
import numpy as np
import pylab
def get_smooth_func():
time = np.linspace(1,40,1000)
freq = 500
freqs = 8000
return np.sin(2*np.pi*freq/freqs*time)
def concat_coeffs(A):
T = A[0]
for i in range(1, len(A)-1):
T = np.append(T, A[i])
return T
def draw():
X = get_smooth_func()
A = pywt.wavedec(X, 'db8', pywt.MODES.ppd, level=4)
C = concat_coeffs(A)
pylab.figure()
pylab.semilogy(C, '-')
pylab.show()
if __name__ == "__main__":
draw()
I forgot the absolute value.