现在我画了一个基于实时的随机正弦图。然后我要把正弦图改成fft图。我在学这门课,还没有画正弦图。发出此警告。”attributeerror函数对象没有属性“T”。我会做错什么?如果你有时间,能给我一个关于fft的提示吗?”
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
import numpy as np
from scipy.fftpack import fft, fftfreq, ifft
class Scope(object):
def __init__(self,
ax,fn,
xmax=10, ymax =1,
xstart=0, ystart=-1 ):
self.xmax = xmax
self.xstart = xstart
self.ymax = ymax
self.ystart = ystart
self.ax = ax
self.ax.set_xlim((self.xstart,self.xmax))
self.ax.set_ylim((self.ystart,self.ymax))
self.x = [0]
self.y = [0]
self.value = 0
self.fn = fn
self.line, = ax.plot([],[])
self.ti = time.time()
print("초기화 완료")
def update(self, i):
def T (self) :
self.tempo = time.time()-self.ti
self.ti = time.time()
return self.tempo
RT = T(self)
self.value = self.fn()
self.y.append(self.value)
self.x.append( RT + self.x[-1])
self.line.set_data(self.x,self.y)
if self.x[-1] >= self.xstart + self.xmax :
self.xstart = self.xstart + self.xmax/2
self.ax.set_xlim(self.xstart,self.xstart + self.xmax)
self.ax.figure.canvas.draw()
return (self.line, )
fig = plt.figure()
ax = plt.subplot(211)
def insert():
TI = scope.update.T()
value = np.sin(TI)
return value
scope = Scope(ax,insert, ystart = -1, ymax = 1)
ani = animation.FuncAnimation(fig, scope.update,interval=10,blit=True)
plt.show()
目前没有回答
相关问题 更多 >
编程相关推荐