I am willing to get 2 random data and plot it in the same Widget using PyQtGraph in a real-time way. I want them to show up as Red and Blue dots. However, after a hard time,
While pyqtgraph is a great package from a functionality perspective, unfortunately the documentation is lacking, and you really just have to dig in to the code and start to understand the structure of the objects.
When you call:
p1 = win.addPlot()
This returns a reference to a PlotItem, at which point you can now add multiple PlotDataItems to this p1 object (see semi-useful structure diagram here : http://www.pyqtgraph.org/documentation/plotting.html#organization-of-plotting-classes )
So when you call:
curve1 = p1.plot()
This adds PlotDataItem #1, ... you now need to call it again to get a second reference to use:
curve2 = p1.plot()
This becomes PlotDataItem #2, which you can then use for the 2nd setData method in your plot() method to call during update(). Which would look like:
def plot():
#Blue Dots
curve1.setData(dataBlue, pen=None, symbol='o', symbolPen=None, symbolSize=4, symbolBrush=('b'))
#Red Dots
curve2.setData(dataRed, pen=None, symbol='o', symbolPen=None, symbolSize=4, symbolBrush=('r'))