I'm developing an app to collect and display experimental data, and control several devices. I'm doing the plotting with a Timer that pulls data from several arrays that are being filled continuously by other QTimer responsible for data collection.
After several hours of collecting and plotting at a rate slower than or equal to 1 point per second, the plotting becomes pretty slow and I don't think it's because I'm running out of memory (8 bytes x 12 hours x 3600 measurements/hour x 5 signals ~ 1.6 MB and I have at least 2GB of RAM) so I think there might be a lag on the re-plotting and clearing of the signals which also happens every second.
Currently I am using:
PlotItem.plot(x, y, clear=True)
to update my plot. Is there a better way to do this? Some function that would add data points to the plot without repotting the whole thing. Having said that I'm going to go ahead and try:
PlotItem.plot(x[-2:-1], y[-2:-1], clear=False)
But this might be a bit involved, as I would have to differentiate fresh and old data. Does anyone have a more elegant solution?
In my experience plotting become noticeably slow at around 100000 points, so with 5 plots of 12*3600 points you reach this point.
You can't add data points incrementally to the graph because then the lines are discontinuous; you will have to replot every data point every time. However, it is possible to do this a bit more efficiently by using the setData
method as explained my answer here.
Also disabling the axes auto-range will help a lot.
Finally, I noticed that plotting becomes really slow if you use anti-aliasing together with a line width larger than 1.0