Aluode/PerceptionLabPortable
0
1 2"""3This example demonstrates the different auto-ranging capabilities of ViewBoxes4"""5 6import time7 8import numpy as np9 10import pyqtgraph as pg11from pyqtgraph.Qt import QtCore12 13app = pg.mkQApp("Plot Auto Range Example")14 15win = pg.GraphicsLayoutWidget(show=True, title="Plot auto-range examples")16win.resize(800,600)17win.setWindowTitle('pyqtgraph example: PlotAutoRange')18 19d = np.random.normal(size=100)20d[50:54] += 1021p1 = win.addPlot(title="95th percentile range", y=d)22p1.enableAutoRange('y', 0.95)23 24 25p2 = win.addPlot(title="Auto Pan Only")26p2.setAutoPan(y=True)27curve = p2.plot()28t0 = time.time()29 30def update():31 t = time.time() - t032 33 data = np.ones(100) * np.sin(t)34 data[50:60] += np.sin(t)35 curve.setData(data)36 37timer = QtCore.QTimer()38timer.timeout.connect(update)39timer.start(50)40 41if __name__ == '__main__':42 pg.exec()43 