added auto-ranging example
This commit is contained in:
parent
038b116aec
commit
7c1c9f8d04
48
examples/PlotAutoRange.py
Normal file
48
examples/PlotAutoRange.py
Normal file
@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
## This example demonstrates the different auto-ranging capabilities of ViewBoxes
|
||||
|
||||
|
||||
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
|
||||
|
||||
#QtGui.QApplication.setGraphicsSystem('raster')
|
||||
app = QtGui.QApplication([])
|
||||
#mw = QtGui.QMainWindow()
|
||||
#mw.resize(800,800)
|
||||
|
||||
win = pg.GraphicsWindow(title="Plot auto-range examples")
|
||||
win.resize(800,600)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||
import sys
|
||||
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||
app.exec_()
|
||||
|
Loading…
Reference in New Issue
Block a user