I am trying to plot multiple data streams on a single plot using PyQt5
. When I use setData
, only the fifth column of the data stream is shown, i.e, I only see data_out[:,4]
and not other columns. How do I implement a hold on
instance of MATLAB
in PyQt5
?
class App(QMainWindow):
def __init__(self):
# initUI
self.initUI()
# define plots axis and labels
self.pc1 = pg.PlotDataItem(name="ACC")
self.pw1.addItem(self.pc1)
self.pw1.setLabel('left', 'LEFT FOOT ACC', units='m/s^2')
self.pw1.setLabel('bottom', 'Time', units='s')
# timer
self.timer = pg.QtCore.QTimer()
def initUI(self):
# create subplot grid
self.pw1 = pg.PlotWidget()
grid_layout.addWidget(self.pw1,2,0,1,4)
# create start/stop button
self.on_start = QPushButton("START")
self.on_stop = QPushButton("STOP")
grid_layout.addWidget(self.on_start,4,0,1,8)
grid_layout.addWidget(self.on_stop,5,0,1,8)
def on_start_clicked(self):
# do something
if not self.timer.isActive():
self.timer.timeout.connect(self.updateplot)
self.timer.start(8)
def on_stop_clicked(self):
# do something
def updateplot(self):
while (self.lcom.loop is True) and (not self.l_queue.empty()):
self.data_out.append(self.l_queue.get())
self.time_out.append(self.t)
if len(self.data_out) != 0:
self.pc1.setData(np.array(self.data_out)[:,2],pen=(255,0,0))
self.pc1.setData(np.array(self.data_out)[:,3],pen=(0,255,0))
self.pc1.setData(np.array(self.data_out)[:,4],pen=(0,0,255))
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())