首页 > 解决方案 > 如何让 matplotlib 绘制多个点

问题描述

我正在做一个项目,我需要在基于 3d 数组的动画中显示点。该数组具有以下形状

(1000,60,2)

其中第一个维度是帧数(因此有 1000 帧),第二个维度是点数(因此每帧需要显示 60 个点),最后一个维度是 x 和 y 坐标(因此是 2) .

我创建了一个简单的更新函数,它只返回每一帧的数据:

fig, ax = plt.subplots()
fig.set_tight_layout(True)
ax.axis([-1,int(boxX + 1),-1,int(boxY + 1)])
point, = ax.plot(0,1, marker="o")

def update(i, posFull, dummy):
    return pos[int(i)]
animation = FuncAnimation(fig, update, fargs=(posFull, 0), interval = 2, frames=np.linspace(0,int(stept - 1), int(stept)))

我假设这会返回如下所示的点列表:

(60,2)

我已经打印了返回的数组,看起来我的假设是正确的,但是当我查看动画时,只显示了一个点。其他 59 点在哪里?我该如何展示它们?

标签: pythonmatplotlibanimation

解决方案


推荐阅读