码迷,mamicode.com
首页 > 其他好文 > 详细

pyqtgraph连续刷新波形图例子

时间:2018-05-28 17:59:15      阅读:1244      评论:0      收藏:0      [点我收藏+]

标签:setw   str   .exe   pen   grid   lob   tar   连续   admin   

技术分享图片

 

 1 # -*- coding: utf-8 -*-#
 2 
 3 #-------------------------------------------------------------------------------
 4 # Name:         1
 5 # Description:  
 6 # Author:       Administrator
 7 # Date:         2018/5/28
 8 #-------------------------------------------------------------------------------
 9 
10 import numpy as np
11 import pyqtgraph as pg
12 
13 app = pg.mkQApp()
14 
15 win = pg.GraphicsWindow()
16 win.setWindowTitle(upyqtgraph plot demo)
17 win.resize(600, 400)
18 
19 p = win.addPlot()
20 p.showGrid(x=True, y=True)
21 p.setLabel(axis=left, text=uAmplitude / V)
22 p.setLabel(axis=bottom, text=ut / s)
23 p.setTitle(y1=sin(x)  y2=cos(x))
24 p.addLegend()
25 
26 curve1 = p.plot(pen=r, name=y1)
27 curve2 = p.plot(pen=g, name=y2)
28 
29 Fs = 1024.0 #采样频率
30 N = 1024    #采样点数
31 f0 = 5.0    #信号频率
32 pha = 0     #初始相位
33 t = np.arange(N) / Fs   #时间向量
34 
35 def plotData():
36     global pha
37     pha += 10
38     curve1.setData(t, np.sin(2 * np.pi * f0 * t + pha*np.pi/180.0))
39     curve2.setData(t, np.cos(2 * np.pi * f0 * t + pha*np.pi/180.0))
40 
41 timer = pg.QtCore.QTimer()
42 timer.timeout.connect(plotData)
43 timer.start(50)
44 
45 app.exec_()

 

pyqtgraph连续刷新波形图例子

标签:setw   str   .exe   pen   grid   lob   tar   连续   admin   

原文地址:https://www.cnblogs.com/luke0011/p/9101288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!