Animating a mayavi points3d plot

前端 未结 2 447
逝去的感伤
逝去的感伤 2020-12-03 14:57

I\'m trying to make a video of the trajectories of particles. However, somehow my scene never updates. Here\'s a very simple example:

from __future__ import          


        
相关标签:
2条回答
  • 2020-12-03 15:23

    Just change to:

    ...

        for (x, y, z) in zip(xs, ys, zs):
            print('Updating scene...')
            plt.mlab_source.set(x=x, y=y, z=z)
            yield
    

    ...

    you don't even need the f.scene.render(), according to documentation mlab_source.set guarantees the refresh.

    Also since shape of your data doesn't change you don't need to use mlab_source.reset.

    I also tested and works fine.

    0 讨论(0)
  • 2020-12-03 15:35

    Have you tried mlab_source.reset? It works even when the length of the x, y, and z arrays are changed.

    In your case, it'll be: plt.mlab_source.reset(x=x,y=y,z=z).

    0 讨论(0)
提交回复
热议问题