I have a numpy array which I initialized outside the loop using np.zeros. This array is updated using some function inside a for a loop. I wish to plot the array as it changes with each iteration.
Most of the answers I have seen here are for lists and not ndarrays. I have seen the following links. Some of them I have tried to modify for my purpose but to no avail.
How to update a plot in matplotlib?
https://github.com/stsievert/python-drawnow/blob/master/drawnow/drawnow.py @Scott Sievert, I saw your code too. But unfortunately, I haven't been able to figure out how to modify it.
Real-time plotting using matplotlib and kivy in Python
Real-time plotting using matplotlib and kivy in Python
Real time trajectory plotting - Matplotlib
https://realpython.com/python-matplotlib-guide/
https://gist.github.com/vaclavcadek/66c9c61a1fac30150514a665c4bcb5dc
http://jakevdp.github.io/blog/2012/08/18/matplotlib-animation-tutorial/
So basically I want to see the value of the ndarray y in real-time. (see the code below)
I am running it as a script.@Scott Staniewicz
from numpy.random import random_sample
from numpy import arange, zeros
x = arange(0, 10)
y = zeros((10, 1))
for i in range(10):
y[i] = sin(random_sample())