How to use numpy arrays correctly during live construction plot, I mean if I use these arrays i push values into and everything is good with the exception of line which starts from (0;0) and points each time on current plot's point, in other words first end stays stable, but second changes it location. What to do with this? Also I don't understand how to pass parameters by reference at animation().
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()