I'm trying to make a video of particle trajectories.
Unfortunately, I can't seem to get it to work quite right.
Here's a very simple
#!/usr/bin/env python from __future__ import absolute_import, division, print_function from mayavi import mlab import numpy as np import math alpha = np.linspace(0, 2*math.pi, 100) xs = np.empty((len(alpha), 2)) ys = np.empty_like(xs) zs = np.zeros_like(xs) xs[:, 0] = 0 xs[:, 1] = 10*np.cos(alpha) ys[:, 0] = 0 ys[:, 1] = 10*np.sin(alpha) mlab.points3d(0,0,0) plt = mlab.points3d(xs, ys, zs) @mlab.animate(delay=100) def anim(): f = mlab.gcf() while True: for (x, y, z) in zip(xs, ys, zs): print('Updating scene...') plt.mlab_source.x = x plt.mlab_source.y = y plt.mlab_source.z = z #plt.mlab_source.set(x=x, y=y, z=z) f.scene.render() yield anim() mlab.show() ---snip---
If I run this script, it shows a window with the two points
and the animation GUI. It also prints a continous stream of
Scene..." messages on the terminal. However, the scene doesn't show any movement at all.
If, instead of the mlab_source.x = assignments, I uncommend
the call to mlab_source.set(), the plot is updating, but I'm
getting a stream of
ERROR: In /build/buildd-vtk_5.8.0-13+b1-amd64-HQvOIO/vtk-5.8.0/Filtering/vtkExecutive.cxx, line 756
vtkStreamingDemandDrivenPipeline (0x68c6870): Algorithm vtkAssignAttribute(0x68c3b20) returned failure for request: vtkInformation (0x6c9b9c0)
Modified Time: 852875
Reference Count: 1
Registered Events: (none)
errors on my terminal.
What am I doing wrong? I'm using Python 2.7, Mayavi 4.1, VTK 5.8.