简体   繁体   中英

How to plot data being read at 12KHz in pyqtgraph on raspberry pi?

My python script runs on a raspberry pi and reads voltage data at 12000 samples per second in chunks of 1200 samples from a LabJack U3. These data are stored in a list, and a time list with values corresponding to each voltage point is created artificially by referring to the voltage data read rate. What is the best way to plot this data (voltage vs. time) in pyqtgraph? I can already plot each data chunk (1200 samples) as they come in, but I need a way to plot many of these chunks in succession in the same plot window as they come in to get a better idea of how the voltage changes over time.

I've been using the scrolling plot examples from the pyqtgraph documentation as a guide but have been having problems plotting the data because of how it comes in as chunks instead of as single points. I don't need to plot at the full 12KHz because of the pixel density of the monitor as well as its refresh rate but have gotten stuck at this point. Can anyone suggest a good way to proceed?

Thanks for your help.

If, as you say, you don't need to plot the full 12000 samples, you can down sample them. The PlotItem.setDownSampling method does exactly that. Or you can do it yourself with Numpy.

There have been some SO post on this topic before, so I would search a bit. For instance this one , which suggests to store the data in a circular buffer (a collections.deque ). This may be useful if you want a scrolling plot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM