matplotlib - 使用 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)
解决方案
推荐阅读
- angular - 如果在 Angular 5 中使用 forkJoin 作为并行请求处理的一部分完成了特定请求,我该如何获取?
- android - Linux Android SDK 中的“工具”和“平台工具”目录在哪里?
- jmeter - 如何从jmeter中的标头读取值?
- javascript - JSON.parse 中位置 0 的 JSON 中的意外标记 u
- javascript - Next.js 在页面路由时保持滚动位置
- excel - 使用用户表单数据,如何仅将字段的前五位数字传输到我的数据库字段(交叉发布)
- java - Eclipse IDE 内部和外部 Tomcat 调用上下文的差异
- raspberry-pi - 如何通过终端将 Raspbian OS 4.14 升级到 4.19
- arrays - BeautifulSoup,请求,数据框保存到 Excel 数组错误
- asp.net - 500 - 内部服务器错误,将 windows server 2012 R2 迁移到 windows server 2016 后