0

我目前有一个数组G = [x,y,t],其中每个空间点(G[0][i], G[1][i])都有一个时间分量t = G[2][i]。该数组按时间排序。我正在尝试为散点图设置动画,以便点按时间顺序显示并且不会消失。这是我当前的代码:

from matplotlib.animation import FuncAnimation
import matplotlib.animation as animation

fig = plt.figure(figsize=(10,7))
ax = plt.subplot(111, xlim=(0,1), ylim=(0,1))

def animationUpdate(k):
    x = G[0][:k]
    y = G[1][:k]
    scat.set_offsets(np.c_[x,y])
    return scat

anim = FuncAnimation(fig, animationUpdate, frames=10, interval=100, blit=True)

我收到错误“'PathCollection' 对象不可迭代”,我不确定如何修复。我也不确定如何安排它,以便点显示相对于它们的时间分量。我要修改 的framesorinterval部分FuncAnimation吗?谢谢!

4

0 回答 0