pyqtgraph/examples/PlotAutoRange.py

45 lines
993 B
Python
Raw Permalink Normal View History

2012-05-08 21:55:25 +00:00
# -*- coding: utf-8 -*-
2013-02-25 04:09:03 +00:00
"""
This example demonstrates the different auto-ranging capabilities of ViewBoxes
"""
2012-05-08 21:55:25 +00:00
import initExample ## Add path to library (just for examples; you do not need this)
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
app = pg.mkQApp("Plot Auto Range Example")
2012-05-08 21:55:25 +00:00
#mw = QtGui.QMainWindow()
#mw.resize(800,800)
win = pg.GraphicsLayoutWidget(show=True, title="Plot auto-range examples")
2012-05-08 21:55:25 +00:00
win.resize(800,600)
2013-02-25 04:09:03 +00:00
win.setWindowTitle('pyqtgraph example: PlotAutoRange')
2012-05-08 21:55:25 +00:00
d = np.random.normal(size=100)
d[50:54] += 10
p1 = win.addPlot(title="95th percentile range", y=d)
p1.enableAutoRange('y', 0.95)
p2 = win.addPlot(title="Auto Pan Only")
p2.setAutoPan(y=True)
curve = p2.plot()
def update():
t = pg.time()
data = np.ones(100) * np.sin(t)
data[50:60] += np.sin(t)
global curve
curve.setData(data)
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(50)
if __name__ == '__main__':
2021-05-13 21:28:22 +00:00
pg.exec()