SO I am have animated a series of frames with Matplotlib
. Now there is a specific point for every frame that I want to mark with a red dot. I have the index of the dot of every frame in a list. How can I add the plotting of the dot to the animation.
here is my code:
data_clean
is the main data that I'm already animating. pred
is the list that contains the dots.
fig = plt.figure(figsize=(10,5))
ax= fig.add_subplot(111,xlabel='Range bins', ylabel='Doppler bins' )
im = ax.imshow(data_clean[0,0,...], vmin= -60, vmax=0, animated=True)
cbar = fig.colorbar(im)
cbar.set_label('dB Full Scale')
#this should scatter the dot
im4 = plt.scatter(*pred[:,0], color="r")
def animate(i):
im3.set_array(data_clean[i,0])
im4.set_array(pred[:,i])
return im3, im4
anim = animation.FuncAnimation(fig, animate,
frames=50, interval=50, blit=False, repeat=True)