Matplotlib在图像上设置动画 [英] Matplotlib animate over an image

查看:44
本文介绍了Matplotlib在图像上设置动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为图像上的一堆不断更新的点设置动画(想象使绘制的点在某些图像上对角移动).我在这里查看了动画示例: http://matplotlib.org/examples/animation/dynamic_image.html ,但是我不确定在清除所有先前的点然后重新绘制它们时如何保持相同的图像.有什么想法吗?

I'm trying to animate a bunch of constantly updating points over an image (imagine making a plotted dot move diagonally across some image). I've looked at the animate examples here: http://matplotlib.org/examples/animation/dynamic_image.html, but I'm not sure how to keep the same image while clearing out all previous dots, then redrawing them. Any ideas?

推荐答案

你不需要清除每一帧之间的图形

You do not need to clear the figure between every frame

#initial data 
ln, = ax.plot(x,y)
#...some loop code
    ln.set_xdata(new_x)
    ln.set_ydata(new_y)

您能否展示一些您尝试过的代码,这样可以更轻松地给出更具体的答案.

Can you show some code of what you have tried, it will make it easier to give a more concrete answer.

另请参阅:在循环中高效使用matplotlib的颤动, 3D-numpy-array 框架的可视化按帧

这篇关于Matplotlib在图像上设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆