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?
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With