Hi Mike, With this approach you are creating as many curve objects as segments, and on top of that you are doing a for loop on each point of your data so it is reasonable to expect it to be very inefficient.
Have you considered deriving from pyqtgraph.PlotDataItem and reimplement its paint() method to pass a different QPainter depending on the segment being painted? Not sure if that would be the best (or simpler) approach, but it is what I would first try... Cheers, Carlos On Wednesday, January 31, 2018 12:37:40 AM CET Mike Oliver wrote: > So I managed to get this working but its incredibly slow on large data > sets. Is there a better way to do this? > > from pyqtgraph.Qt import QtGui, QtCore > import pyqtgraph as pg > import numpy as np > > win = pg.GraphicsWindow() > p1 = win.addPlot() > values = [10,50,8,64,45,9,6,12,6,43,3,7,33,67,82,42,12,7,40,8] > > for i in range(len(values)-1): > if values[i]>values[i+1]: > p1.plot([i,i+1],values[i:i+2], pen=(255,0,0)) > else: > p1.plot([i,i+1],values[i:i+2], pen=(0,255,0)) > > if __name__ == '__main__': > import sys > if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'): > QtGui.QApplication.instance().exec_() -- +----------------------------------------------------+ Carlos Pascual Izarra Scientific Software Coordinator Computing Division ALBA Synchrotron [http://www.albasynchrotron.es] Carrer de la Llum 2-26 E-08290 Cerdanyola del Valles (Barcelona), Spain E-mail: [email protected] Phone: +34 93 592 4428 +----------------------------------------------------+ -- 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/14879600.LW1T3PAr7a%40pc218. For more options, visit https://groups.google.com/d/optout.
