Original version in MATLAB available at link
python example.py
Note this requires data in a mat file which can be generated using function sample_data
in data_simulator.py
For LaTeX typesetting in the plots, some TeX libraries are required. Try installing with MacTeX (for MacOS) and some more packages with TeX Live Manager:
tlmgr install dvipng type1cm