首页 > 解决方案 > 使用 Matplotlib 对 2 个不同的绘图进行动画处理

问题描述

所以我用Matplotlib. 现在,我想用红点标记每一帧都有一个特定的点。我有列表中每一帧的点的索引。如何将点的绘图添加到动画中。这是我的代码: data_clean是我已经在制作动画的主要数据。pred是包含点的列表。

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)  

标签: matplotlibanimation

解决方案


推荐阅读