Aluode/PerceptionLabPortable
0
1#!/usr/bin/python2 3import numpy as np4 5import pyqtgraph as pg6from pyqtgraph.Qt import QtCore7from utils import FrameCounter8 9app = pg.mkQApp("Infinite Line Performance")10 11p = pg.plot()12p.setWindowTitle('pyqtgraph performance: InfiniteLine')13p.setRange(QtCore.QRectF(0, -10, 5000, 20))14p.setLabel('bottom', 'Index', units='B')15curve = p.plot()16 17# Add a large number of horizontal InfiniteLine to plot18for i in range(100):19 line = pg.InfiniteLine(pos=np.random.randint(5000), movable=True)20 p.addItem(line)21 22data = np.random.normal(size=(50, 5000))23ptr = 024 25def update():26 global ptr27 curve.setData(data[ptr % 10])28 ptr += 129 framecnt.update()30 31 32timer = QtCore.QTimer()33timer.timeout.connect(update)34timer.start(0)35 36framecnt = FrameCounter()37framecnt.sigFpsUpdate.connect(lambda fps: p.setTitle(f'{fps:.1f} fps'))38 39if __name__ == '__main__':40 pg.exec()41 