I am using PyQtgraph with PySide2 to plot some large datasets. This works fine with the smaller datasets, but when I start getting up into the hundreds of thousands of data points - the attached sample image contains 159,936 data points, for example - zooming and panning gets VERY laggy. I’m guessing this is simply due to Qt trying to re-draw all 159,936 data points whenever something changes?
I tried using the clipToView() option, but that crashed and burned (and wouldn’t help much when viewing the entire dataset anyway):
Traceback (most recent call last):
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 885, in viewRangeChanged
self.updateItems(styleUpdate=False)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 620, in updateItems
self.scatter.setData(x=x, y=y, **scatterArgs)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 483, in setData
self.addPoints(*args, **kargs)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 599, in addPoints
self.setPointData(kargs['data'], dataSet=newData)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 753, in setPointData
raise Exception("Length of meta data does not match number of points (%d != %d)" % (len(data), len(dataSet)))
Exception: Length of meta data does not match number of points (50 != 2)
Traceback (most recent call last):
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 885, in viewRangeChanged
self.updateItems(styleUpdate=False)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 620, in updateItems
self.scatter.setData(x=x, y=y, **scatterArgs)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 483, in setData
self.addPoints(*args, **kargs)
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 589, in addPoints
setMethod(kargs[k], update=False, dataSet=newData, mask=kargs.get('mask', None))
File "/Users/israel/Development/tropomi_gui/lib/python3.8/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 668, in setBrush
raise Exception("Number of brushes does not match number of points (%d != %d)" % (len(brushes), len(dataSet)))
Exception: Number of brushes does not match number of points (159936 != 36657)
So then I got the thought of simply “rendering” all the data points to a single QPixmap or the like, and simply displaying that at the appropriate location and size. And that’s where I got stuck: I can’t figure out how to a) render the data to an image object, or b) how to figure out the appropriate location and size.
Is this a reasonable and valid approach? If so, can anyone give me some tips as to how I might go about it? Is there a better way? Thanks!