title: How to plot two real-time data in one single plot in PyQtGraph?
body: <p>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, my script does not work.</p>
  
  <p>I would like to know what can I do in order to get both data in the same plot.</p>
  
  <p>I know it is a silly question. I am a beginner in Python and coding. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>#-*- coding: utf-8 -*-
  import random
  import time
  from collections import deque
  import pyqtgraph as pg
  from pyqtgraph.Qt import QtCore, QtGui
  import numpy as np
  import os
  import spidev
  
  win = pg.GraphicsWindow()
  win.setWindowTitle('DOTS')
  
  
  p1 = win.addPlot()
  p1.setRange(yRange=[0,25])
  p1.setRange(xRange=[0,25])
  curve1 = p1.plot()
  
  
  nsamples=300 #Number of lines for the data
  
  dataRed= np.zeros((nsamples,2),float) #Matrix for the Red dots
  dataBlue=np.zeros((nsamples,2),float) #Matrix for the Blue dots
  
  def getData():
      global dataRed, dataBlue
  
      t0= random.uniform(1.6,20.5) #Acquiring Data
      d0= random.uniform(1.6,20.5) #Acquiring Data
      vec=(t0, d0)
  
      dataRed[:-1] = dataRed[1:]
      dataRed[-1]=np.array(vec)
  
      t0= random.uniform(1.6,20.5) #Acquiring Data
      d0= random.uniform(1.6,20.5) #Acquiring Data
      vec=(t0, d0)
  
      dataBlue[:-1] = dataBlue[1:]
      dataBlue[-1]=np.array(vec)
  
  
  def plot():
  
      #Blue Dots
      curve1.setData(dataBlue, pen=None, symbol='o', symbolPen=None, symbolSize=4, symbolBrush=('b'))
      #Red Dots
      curve1.setData(dataRed, pen=None, symbol='o', symbolPen=None, symbolSize=4, symbolBrush=('r'))   
  
  
  def update():
  
      getData()
      plot()
  
  timer = pg.QtCore.QTimer()
  timer.timeout.connect(update)
  timer.start(50)
  
  ## Start Qt event loop unless running in interactive mode or using pyside.
  if __name__ == '__main__':
      import sys
      if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
          QtGui.QApplication.instance().exec_()# -*- coding: utf-8 -*-
  </code></pre>
  
  <p>I would really appreciate your help.</p>