Is it possible to update matplotlib quiver position coordinates in an animation?

匿名 (未验证) 提交于 2019-12-03 09:06:55

问题:

I'd like to draw and animate some particles with matplotlib. Each point has a position and velocity. I am able to draw single frames using matplotlib quiver.

But how can I update the quiver data for each frame? (I am using the matplotlib animation class.) I read about the (undocumented?) quiver.set_UVC(), but that seems to update only the direction, not position. Is there any other way to do this?

回答1:

The comment I left (now deleted) was incorrect. You can do this via the Collections level method set_offsets (doc).

X, Y = np.meshgrid(linspace(0, 100), linspace(0, 100)) q = plt.quiver(X, Y , rand(100, 100), rand(100, 100)) plt.draw() plt.pause(2) q.set_offsets(q.get_offsets() * np.array([1, .5])) plt.draw() 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!