2010-03-22 05:48:52 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
2010-03-22 06:21:56 +00:00
|
|
|
## Add path to library (just for examples; you do not need this)
|
|
|
|
import sys, os
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
2010-03-22 05:48:52 +00:00
|
|
|
|
|
|
|
from scipy import random
|
2011-02-03 10:03:13 +00:00
|
|
|
from numpy import array, arange
|
2010-03-22 05:48:52 +00:00
|
|
|
from PyQt4 import QtGui, QtCore
|
2010-03-22 06:21:56 +00:00
|
|
|
from pyqtgraph.PlotWidget import *
|
|
|
|
from pyqtgraph.graphicsItems import *
|
2010-03-22 05:48:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
app = QtGui.QApplication([])
|
|
|
|
mw = QtGui.QMainWindow()
|
|
|
|
cw = QtGui.QWidget()
|
|
|
|
mw.setCentralWidget(cw)
|
|
|
|
l = QtGui.QVBoxLayout()
|
|
|
|
cw.setLayout(l)
|
|
|
|
|
|
|
|
pw = PlotWidget()
|
|
|
|
l.addWidget(pw)
|
|
|
|
pw2 = PlotWidget()
|
|
|
|
l.addWidget(pw2)
|
|
|
|
pw3 = PlotWidget()
|
|
|
|
l.addWidget(pw3)
|
|
|
|
|
|
|
|
pw.registerPlot('Plot1')
|
|
|
|
pw2.registerPlot('Plot2')
|
|
|
|
|
|
|
|
#p1 = PlotCurveItem()
|
|
|
|
#pw.addItem(p1)
|
|
|
|
p1 = pw.plot()
|
|
|
|
rect = QtGui.QGraphicsRectItem(QtCore.QRectF(0, 0, 1, 1))
|
|
|
|
rect.setPen(QtGui.QPen(QtGui.QColor(100, 200, 100)))
|
|
|
|
pw.addItem(rect)
|
|
|
|
|
2010-07-24 18:29:09 +00:00
|
|
|
#pen = QtGui.QPen(QtGui.QBrush(QtGui.QColor(255, 255, 255, 50)), 5)
|
|
|
|
#pen.setCosmetic(True)
|
2010-03-22 05:48:52 +00:00
|
|
|
#pen.setJoinStyle(QtCore.Qt.MiterJoin)
|
2010-07-24 18:29:09 +00:00
|
|
|
#p1.setShadowPen(pen)
|
|
|
|
p1.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255)))
|
2010-03-22 05:48:52 +00:00
|
|
|
|
|
|
|
#l1 = QtGui.QGraphicsLineItem(0, 2, 2, 3)
|
|
|
|
#l1.setPen(QtGui.QPen(QtGui.QColor(255,0,0)))
|
2010-07-24 18:29:09 +00:00
|
|
|
|
|
|
|
#l2 = InfiniteLine(pw2, 1.5, 90, movable=True)
|
|
|
|
#
|
|
|
|
#lr1 = LinearRegionItem(pw2, 'vertical', [1.1, 1.3])
|
|
|
|
#pw2.addItem(lr1)
|
|
|
|
#lr2 = LinearRegionItem(pw2, 'horizontal', [50, 100])
|
|
|
|
#pw2.addItem(lr2)
|
|
|
|
|
|
|
|
|
2010-03-22 05:48:52 +00:00
|
|
|
#l3 = InfiniteLine(pw, [1.5, 1.5], 45)
|
|
|
|
#pw.addItem(l1)
|
2010-07-24 18:29:09 +00:00
|
|
|
#pw2.addItem(l2)
|
2010-03-22 05:48:52 +00:00
|
|
|
#pw.addItem(l3)
|
|
|
|
|
|
|
|
pw3.plot(array([100000]*100))
|
|
|
|
|
|
|
|
|
|
|
|
mw.show()
|
|
|
|
|
|
|
|
|
|
|
|
def rand(n):
|
|
|
|
data = random.random(n)
|
|
|
|
data[int(n*0.1):int(n*0.13)] += .5
|
|
|
|
data[int(n*0.18)] += 2
|
|
|
|
data[int(n*0.1):int(n*0.13)] *= 5
|
|
|
|
data[int(n*0.18)] *= 20
|
|
|
|
return data, arange(n, n+len(data)) / float(n)
|
|
|
|
|
|
|
|
|
|
|
|
def updateData():
|
|
|
|
yd, xd = rand(10000)
|
|
|
|
p1.updateData(yd, x=xd)
|
|
|
|
|
|
|
|
yd, xd = rand(10000)
|
|
|
|
updateData()
|
|
|
|
pw.autoRange()
|
|
|
|
|
|
|
|
t = QtCore.QTimer()
|
2010-07-24 18:29:09 +00:00
|
|
|
|
2010-03-22 05:48:52 +00:00
|
|
|
QtCore.QObject.connect(t, QtCore.SIGNAL('timeout()'), updateData)
|
|
|
|
t.start(50)
|
|
|
|
|
2010-07-24 18:29:09 +00:00
|
|
|
|
2010-03-22 05:48:52 +00:00
|
|
|
for i in range(0, 5):
|
|
|
|
for j in range(0, 3):
|
|
|
|
yd, xd = rand(10000)
|
2011-02-08 00:40:38 +00:00
|
|
|
pw2.plot(y=yd*(j+1), x=xd, params={'iter': i, 'val': j})
|
2010-03-22 05:48:52 +00:00
|
|
|
|
2011-02-03 10:03:13 +00:00
|
|
|
app.exec_()
|