Just thinking out loud here: the above section of code is already being executed on a separate thread, in the hope of freeing up the main thread. The main thread receives a signal when the above processing is complete, and then updates the plot on the UI.
In other applications, I've used an external plotting file with matplotlib, which returns the plot has bytes to the main application/thread, which worked really well. Is this an option with pyqtgraph? If so, would running the plot as an external file and returning the plot as bytes be faster than the above approach? I can't imagine it would be, as the above approach appears to be the most direct. Another question: my entire application is based on the use of QtWidgets.QOpenGLWidgets; does this mean the viewPort for the PlotWidget() automatically uitilises OpenGL rendering? I tried setting the viewPort rendering to OpenGL explicitly, but was receiving the "EGLFS: opengl windows cannot be mixed with others" error. Any guidance/clarification would be greatly appreciated as always! Jamie On Mon, Aug 21, 2017 at 6:22 PM, James Ross-Smith <[email protected]> wrote: > > G'day, > > I've written a basic line plotter which holds ~10s (600 data points at > 60Hz) worth of data, which continuously scrolls to the left to mimic a > real-time data feed. > > I've done this by populating a list, which appends new data each > iteration, whilst removing the same number of data points from the > beginning of the list. I've also added some threshold lines (an upper and > lower), as well as an x-axis line. The below code should give an indication > as to the approach I've taken: > > Plot = pyqtgraph.PlotWidget() > > > > DataList = [] > for x in range(0, 600): > DataList.append(DataSource[x]) > > > Plot.clear() > curve = Plot.plot([float(i) for i in DataList], clickable=False) > > > LowerThresholdList = [] > UpperThresholdList = [] > XAxisList = [] > > > for x in range(0, 600): > LowerThresholdList.append(float(LowerThresholdValue)) > UpperThresholdList.append(float(UpperThresholdValue)) > > > XAxisList.append(0) > > > Plot.plot(LowerThresholdList, pen=(255,165,0)) > > Plot.plot(UpperThresholdList, pen=(255,0,0)) > Plot.plot(XAxisList) > > > > I played with InfiniteLines in place of the threshold and x-axis lines, > but prefer how the above lines don't reach the y axis, whereas the > InfiniteLine continues all the way to the axis (as the name would suggest). > > When I run the above on my development machine, it works perfectly, with > the plot updating and scrolling at the full 60Hz refresh rate. When I > deploy the software to my embedded device (currently prototyping on a > Raspberry Pi 2 with EGLFS and OpenGL-enabled), the entire UI becomes > sluggish beyond about 1Hz. My question: is the above approach the best way > of achieving a real-time scrolling line plot? Is replacing the threshold > and x axis plots with InfiniteLines a faster/more efficient approach? The > aim is to have full 60Hz scrolling updates of the data on the embedded > device; if the above approach/selection of PlotWidget/etc. isn't suitable, > can you please point me in the right direction? > > Many thanks, > > Jamie > > -- > You received this message because you are subscribed to a topic in the > Google Groups "pyqtgraph" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/pyqtgraph/3CPo_qm071Q/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/pyqtgraph/475a8259-49dd-4e7f-a4b1-889d1dfd52ff%40googlegroups.com > <https://groups.google.com/d/msgid/pyqtgraph/475a8259-49dd-4e7f-a4b1-889d1dfd52ff%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAFH0v3aS08z1tTGDCf%3DGdL1gNDHgtzPak6J%3Dp6WQbd0dEw%2BEiA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
