【发布时间】:2021-07-24 05:45:07
【问题描述】:
如何在实时构建图中正确使用 numpy 数组,我的意思是,如果我使用这些数组,我会将值推送到其中,除了从 (0;0) 开始的线和每次都指向当前绘图点的线外,一切都很好,换句话说,第一端保持稳定,但第二端改变了它的位置。该怎么办?另外我不明白如何在动画()处通过引用传递参数。
s = '.........................................................................................'+
string.ascii_uppercase
letters = [s[randint(0, len(s)-1)] for _ in range(5000)] #массив букв
time = [i for i in range(5000)]
example = [randint(0, 100) for _ in range(5000)]
t = count()
frequency = 0
time_x = np.zeros(len(time))
key_y = np.zeros(len(time))
cnt = 0
def animate(i):
global cnt
time_x[cnt] = time[cnt]
key_y[cnt] = example[cnt]
print (time_x[cnt], key_y[cnt])
plt.cla()
plt.plot(time_x, key_y)
cnt += 1
ani = FuncAnimation(plt.gcf(), animate, interval=3000)
plt.show()
【问题讨论】:
标签: python numpy matplotlib animation plot