Search code examples
pythonmatplotlibscipywaveletpywt

Wavelet plot with Python libraries


I know that SciPy has some signal processing tools for wavelets in scipy.signal.wavelets and a chart can be drawn using Matplotlib, but it seems I can't get it right. I have tried plotting a Daubechies wavelet against a linear space, but it's not what I am looking for. I am highly unskilled about wavelets and math in general . :)


Solution

  • With a recent trunk version of PyWavelets, getting approximations of scaling function and wavelet function on x-grid is pretty straightforward:

    [phi, psi, x] = pywt.Wavelet('db2').wavefun(level=4)
    

    Note that x-grid output is not available in v0.1.6, so if you need that you will have to use the trunk version.

    Having that data, you can plot it using your favourite plotting package, for example:

    import pylab
    pylab.plot(x, psi)
    pylab.show()
    

    A very similar method is used on wavelets.pybytes.com demo page, but there the charts are done with Google Charts for online presentation.