Marco Massaro
2014-11-17 11:48:55 UTC
Hello,
I need to build an updating plot using 3 curves. I have tried with this
following code but the resultant plot is drastically slower than one single
plot:
#!/usr/bin/python
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import time
import numpy as np
app = QtGui.QApplication([])
win = pg.GraphicsWindow()
p1 = win.addPlot()
p2 = win.addPlot()
p3 = win.addPlot()
curve1 = p1.plot()
curve2 = p2.plot()
curve3 = p3.plot()
readData = [0.0, 0.0, 0.0]
y1=[0.0]
y2=[0.0]
y3=[0.0]
temp = [0.0]
start = time.time()
def update():
global curve1, curve2, curve3
t = time.time()-start # measure of time as x-coordinate
readData= readfun() #it returns a list of 3 elements that have
to be the y-coordinates for the updating plots
y1.append(readData[0])
y2.append(readData[1])
y3.append(readData[2])
temp.append(t)
curve1.setData(temp,y1)
curve2.setData(temp,y2)
curve3.setData(temp,y3)
app.processEvents()
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_'):
QtGui.QApplication.instance().exec_()
I need to build an updating plot using 3 curves. I have tried with this
following code but the resultant plot is drastically slower than one single
plot:
#!/usr/bin/python
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import time
import numpy as np
app = QtGui.QApplication([])
win = pg.GraphicsWindow()
p1 = win.addPlot()
p2 = win.addPlot()
p3 = win.addPlot()
curve1 = p1.plot()
curve2 = p2.plot()
curve3 = p3.plot()
readData = [0.0, 0.0, 0.0]
y1=[0.0]
y2=[0.0]
y3=[0.0]
temp = [0.0]
start = time.time()
def update():
global curve1, curve2, curve3
t = time.time()-start # measure of time as x-coordinate
readData= readfun() #it returns a list of 3 elements that have
to be the y-coordinates for the updating plots
y1.append(readData[0])
y2.append(readData[1])
y3.append(readData[2])
temp.append(t)
curve1.setData(temp,y1)
curve2.setData(temp,y2)
curve3.setData(temp,y3)
app.processEvents()
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_'):
QtGui.QApplication.instance().exec_()
--
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 pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/1629b1c8-1377-48e5-81be-f9efcbddc34e%40googlegroups.com.
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 pyqtgraph+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/1629b1c8-1377-48e5-81be-f9efcbddc34e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.