参考文献:https://baijiahao.baidu.com/s?id=1612731984727714937&wfr=spider&for=pc
https://docs.scipy.org/doc/scipy-0.19.0/reference/signal.html
加上滤波
import pyqtgraph as pg
import numpy as np
import array
from scipy import signal
b, a = signal.butter(3, 0.05)
zi = signal.lfilter_zi(b, a)
dss = zi
app = pg.mkQApp()
data = array.array('d')
data2 = array.array('d')
data3 = array.array('d')
# print(data)
N = 200
win = pg.GraphicsWindow()
win.setWindowTitle(u'pyqtgraph逐点画波形图')
win.resize(500,300)
p = win.addPlot()
p.showGrid(x=True,y=True)
p.setRange(xRange=[0,N-1],yRange=[-1.2,1.2],padding=0)
p.setLabels(left='y / V',bottom='x / point',title='y = sin(x)')
curve = p.plot(pen='y')
# q = win.addPlot()
filter_curve = p.plot(pen='y')
filter_curve_2 = p.plot(pen='y')
idx = 0
def plotData():
global idx
global dss
global data3
tmp =signal_xHz(1, 1,50, idx )# np.sin(np.pi / 50 * idx)
# print('dss',dss,'tmp',tmp)
z, dss = signal.lfilter(b, a, tmp, zi=dss)
if len(data)
filtfilt要多于12个点才能滤波,所以直接200个点后,才使用filtfilt滤波。