I have an array of arrays with format [2000][200,3]
that I am creating an animated scatter plot of. 2000 is the number of frames and the interior arrays have format [length, [x,y,inten]]
which are the points to scatter.
So for an example a single frame will look like:
Array[0]=np.array([x_1,y_1,I_1],[x_2,y_2,I_2],...,[x_200,y_200,I_200])
So we have 2000 frames of 200 points each. These points are arbitrarily truncated every 200 and are actually sequential. So I can feasibly reshape the array into:
Array=np.array(np.array([x_1,y_1,I_1],[x_2,y_2,I_2],...,[x_400000,y_400000,I_400000])
Which is no problem for me. I know how to do this.
My question is how can I animate a scatter plot that adaptively moves through the points instead of displaying 200 point bins? The code below allows me to plot an animated scatter plot with frames (1-200,201-400,401-600,etc) but the result is not very smooth to the eye. Ideally I would like something that updates at every point or at least every 10 points so for example frames (1-200,2-201,3-202,etc) or (1-200,11-210,21-200,etc)
numframes=len(Array)
plt.ion()
fig, ax = plt.subplots()
norm = plt.Normalize(Array[:][:,2].min(), Array[:][:,2].max())
sc = ax.scatter(Array[0][:,0], Array[0][:,1], c=Array[0][:,2], cmap=cm.hot, s=5)
plt.xlim(-40,40)
plt.ylim(0,200)
plt.draw()
for i in range(numframes):
sc.set_offsets(np.c_[Array[i][:,0], Array[i][:,1]])
sc.set_array(Array[i][:,2])
print(i)
plt.pause(0.1)
plt.ioff()
plt.show()