Matplotlib:设置大数据的动画

2024-09-29 22:00:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我有20个人体关节在XYZ CSV文件,我需要动画,然后在XY轴和ZY轴。我使用pandas从CSV文件和scatter set_offsets收集数据

我把收集到的数据

def _update_plot_XY(self, i, fig, scat):
    scat.set_offsets((
        (self.data.HeadX[i], self.data.HeadY[i]),
        (self.data.ShoulderCenterX[i], self.data.ShoulderCenterY[i]),
        (self.data.SpineX[i], self.data.SpineY[i]),
        (self.data.HipCenterX[i], self.data.HipCenterY[i]),
        (self.data.ShoulderLeftX[i], self.data.ShoulderLeftY[i]),
        (self.data.ElbowLeftX[i], self.data.ElbowRightY[i]),
        (self.data.WristRightX[i], self.data.WristRightY[i]), (self.data.HandRightX[i], self.data.HandRightY[i]),
        (self.data.HandLeftX[i], self.data.HandLeftY[i]),
        (self.data.ShoulderRightX[i], self.data.ShoulderRightY[i]),
        (self.data.ElbowRightX[i], self.data.ElbowRightY[i]),
        (self.data.WristLeftX[i], self.data.WristLeftY[i]), (self.data.HipLeftX[i], self.data.HipLeftY[i]),
        (self.data.KneeLeftX[i], self.data.KneeLeftY[i]),
        (self.data.AnkleLeftX[i], self.data.AnkleLeftY[i]),
        (self.data.FootLeftX[i], self.data.FootLeftY[i]), (self.data.HipRightX[i], self.data.HipRightY[i]),
        (self.data.KneeRightX[i], self.data.KneeRightY[i]),
        (self.data.AnkleRightX[i], self.data.AnkleRightY[i]), (self.data.FootRightX[i], self.data.FootRightY[i])))
    return scat

我知道FPS是33

self.anim_XY = animation.FuncAnimation(self.fig, self.human._update_plot_XY, fargs=(self.fig, scat2),
                                             frames=self.human.frames, interval=33, repeat=False)

我试着把每一张图都画成新的图形,但看起来很糟糕。 有没有其他选择来提高FPS?你知道吗


Tags: 文件csv数据selfdataplotfigupdate

热门问题