0

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)  
hamid.khb
  • 432
  • 2
  • 11
  • Does this answer your question? [How to animate a scatter plot?](https://stackoverflow.com/questions/9401658/how-to-animate-a-scatter-plot) – Diziet Asahi Mar 26 '20 at 13:59
  • @DizietAsahi I dont have problem to plot a scatter. my problem is to plot the scatter and the image on top of each other. Like ploting to different lines in the same figure. – hamid.khb Mar 30 '20 at 07:31

0 Answers0