I’ve written a Python script that reads and stores 15000 data points (voltage readings) per second as they are streamed from a LabJack U3-HV connected to a function generator. I am using Python’s multiprocessing to read the voltage data from the LabJack at 15000 Hz in one process, passing the data through a pipe to the second process where it is stored in a list and where the plotting takes place in real time.
I am trying to draw the voltage sine wave from the function generator (voltage vs. time) in real time as the voltage data is being streamed from the LabJack. I also need to plot the Fourier transform of this data in real time simultaneously.
The time list is created by referring to the 1/rate at which the voltage readings take place. Without plotting in real time the script can store the voltage and time data accurately up to 15000 samples per second. The problem only comes in when I try to plot in real time with Matplotlib.
I am currently using Matplotlib with the drawnow() function to draw and update the plot in real time. This process works but is far too slow to be practically useable in experiments.
Can anyone suggest the best method (other plotting libraries, better use of Matplotlib, etc.) to plot this voltage sine wave (voltage vs. time) and Fourier transform accurately in real time?
Thanks for you help.
I haven't done plotting in Python, but looking at Matplotlib it looks like you can improve performance with an animated plot and blitting:
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Animations.html
If you want to try a different library, here are some other ones to look into: Bokeh, VisPy and PyQtGraph . I've seen these mentioned in various online discussions and there are more than just these.