pyqtgraph连续刷新波形图例子
Posted lgk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyqtgraph连续刷新波形图例子相关的知识,希望对你有一定的参考价值。
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(u\'pyqtgraph 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=u\'Amplitude / V\') 22 p.setLabel(axis=\'bottom\', text=u\'t / 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连续刷新波形图例子的主要内容,如果未能解决你的问题,请参考以下文章