-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSW_fft_visualization_plot.py
38 lines (32 loc) · 1.26 KB
/
SW_fft_visualization_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import ui_plot #this was generated by pyuic4 command
import sys
import numpy
from PyQt4 import QtCore, QtGui
import PyQt4.Qwt5 as Qwt
numPoints=1000
xs=numpy.arange(numPoints)
ys=numpy.sin(3.14159*xs*10/numPoints) #this is our data
def plotSomething():
global ys
ys=numpy.roll(ys,-1)
c.setData(xs, ys)
uiplot.qwtPlot.replot()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
win_plot = ui_plot.QtGui.QMainWindow()
uiplot = ui_plot.Ui_win_plot()
uiplot.setupUi(win_plot)
# tell buttons what to do when clicked
uiplot.btnA.clicked.connect(plotSomething)
uiplot.btnB.clicked.connect(lambda: uiplot.timer.setInterval(100.0))
uiplot.btnC.clicked.connect(lambda: uiplot.timer.setInterval(10.0))
uiplot.btnD.clicked.connect(lambda: uiplot.timer.setInterval(1.0))
# set up the QwtPlot (pay attention!)
c=Qwt.QwtPlotCurve() #make a curve
c.attach(uiplot.qwtPlot) #attach it to the qwtPlot object
uiplot.timer = QtCore.QTimer() #start a timer (to call replot events)
uiplot.timer.start(100.0) #set the interval (in ms)
win_plot.connect(uiplot.timer, QtCore.SIGNAL('timeout()'), plotSomething)
# show the main window
win_plot.show()
sys.exit(app.exec_())