# Wavelet transform 3D plot for CoP

I'm trying to perform wavelet transform and make a 3D plot like :

With the wavelet transform function :

$$\textrm{CWT}_x^\psi (\tau, s)=\frac{1}{\sqrt{\lvert s\rvert}}\int x(t)\psi\left(\frac{t-\tau}{s}\right)dt$$

Where $t$ is translation and $s$ is scale.

These are MATLAB and Python functions for wavelet transform:

• MATLAB:

[coefs,sgram,frequencies] = cwt(x,scales,wname, samplingperiod,'scale')

• Python:

pywt.wavedec(data, wavelet, mode='sym', level=None)
(cA, cD) = dwt(data, wavelet, mode='sym')
scipy.signal.cwt(data, wavelet, widths)

I know to analyze the signal I have to move the wavelet (translation) to cover all of the signal. The functions of both MATLAB and Python need scales as parameter but there is nothing about translation. The $x$-axis is scales, the $y$-axis is translation.

1. I assumed $z$ is 2D (surface) because I need the coloring but I dont know what it is. Is it coefficients ?
2. what are approximation and detail coefficients ?
3. And what's translation? Is it one to length of my data array (number of data points) ?

I'm new in DSP and I'm confused if anyone can help me I'll appreciate it.

Update :

my data:

0.01009
0.010222
0.010345
0.010465
0.010611
0.010768
0.01089
0.011049
0.011206
0.011329
0.011465
0.011613
0.011763
0.011888
0.012015
0.012154
0.012282
0.012408
0.012524
0.012664
0.012791
0.012918
0.013043
0.013157
0.013284
0.0134
0.013516
0.013666
0.013793
0.013909
0.014024
0.014143
0.014271
0.014398
0.014515
0.014618
0.014722
0.01484
0.014957
0.015075
0.015192
0.015298
0.01539
0.015493
0.015598
0.015695
0.015776
0.015884
0.015978
0.016073
0.016157
0.016254
0.016363
0.016473
0.016572
0.016694
0.016803
0.016913
0.017021
0.017154
0.017242
0.017342
0.01745
0.017555
0.017648
0.017743
0.017851
0.017957
0.018065
0.018194
0.01831
0.018439
0.018582
0.018713
0.018843
0.018995
0.019137
0.0193
0.019464
0.019625
0.019781
0.019945
0.020124
0.020304
0.020447
0.020619
0.020762
0.020931
0.021088
0.021254
0.021398
0.021531
0.021648
0.021814
0.021965
0.022109
0.022251
0.022408
0.022563
0.022748


I used morlet wavelet , 1:150 scale and I got this result:

I get trough at scales 50, 150 , 250 , ... and peaks at 100, 200, 300 , ... Why?

Basically, I see a plot of a 2D function of discretized scale and translation parameters. Instead of a smooth 2D surface, it looks like 1D plots of coefficients at all scales $s_n$, put behind each other along each location $\tau_n$ on the translation axis. And each 1D plot is colored in a level-set fashion: the "vertical" coloring below the 1D curve is related to the amplitude, potentially with color cycling: red for low amplitudes, then yellow, green, cyan, blue, magenta, red (for high amplitudes). This is apparently an instance of a waterfall plot:

curves are staggered both across the screen and vertically, with 'nearer' curves masking the ones behind

with amplitude coloring. So:

1. Coefficients (absolute value) gives you the height of the 1D curve (top) and the coloring below.
2. You don't have approximations and details with CWT. This is not DWT. "Only" low-scale to high-scale "detail" coefficients. There is not father wavelet or scaling function in that case.
3. Yes, without special settings, standard wavelet codes compute coefficients at each sample.

Alternatively, you can draw ribbon plots, with a Matlab code for the color (ribboncoloredZ.m):

• So coefs are the amplitude value (and color) in the plot at scale value x and data index y ? thank you so much. – user22777 Jul 4 '16 at 20:10
• yes, a form of waterfall, I have added a few details – Laurent Duval Jul 4 '16 at 20:30
• You will have to define the $X$ and $Y$ with meshgrid. Apparently you can do coefs = cwt(x,scales,'wname','plot'). – Laurent Duval Jul 4 '16 at 20:42