I currently have an array G = [x,y,t]
where each spatial point (G[0][i], G[1][i])
has a time component t = G[2][i]
. The array is sorted by time. I am trying to animate the scatter plot so points show up in chronological order and do not disappear. Here is my current code:
from matplotlib.animation import FuncAnimation
import matplotlib.animation as animation
fig = plt.figure(figsize=(10,7))
ax = plt.subplot(111, xlim=(0,1), ylim=(0,1))
def animationUpdate(k):
x = G[0][:k]
y = G[1][:k]
scat.set_offsets(np.c_[x,y])
return scat
anim = FuncAnimation(fig, animationUpdate, frames=10, interval=100, blit=True)
I get the error "'PathCollection' object is not iterable" which I am not sure how to fix. I am also unsure how to arrange it so the points show up with respect to their time component. Do I modify the frames
or interval
section of FuncAnimation
? Thanks!