【问题标题】:Is it possible to update matplotlib quiver position coordinates in an animation?是否可以在动画中更新 matplotlib 颤动位置坐标?
【发布时间】:2019-10-22 20:22:33
【问题描述】:

我想用 matplotlib 绘制和动画一些粒子。每个点都有一个位置和速度。我可以使用 matplotlib quiver 绘制单帧。

但是如何更新每一帧的颤动数据呢? (我正在使用 matplotlib 动画类。)我读到了(未记录的?)quiver.set_UVC(),但这似乎只更新了方向,而不是位置。有没有其他方法可以做到这一点?

【问题讨论】:

  • 不重复,@ali_m,因为 set_UVC() 不允许你更新位置,这是我要问的。

标签: python matplotlib


【解决方案1】:

您可以通过Collections 级别方法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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多