Python mayavi: Adding points to a 3d scatter plot -
i'm writing python application simulate motion of particles in 3-space. i'd plot positions each step, updating plot app runs, keeping past positions on plot.
i'd mayavi, far can tell, 1 cannot add points existing scatter plot, must add points in 1 go. not want. want add few points @ time without having keep past points in memory redraw them @ each step.
the function i've been looking @ plot3d().
http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#mayavi.mlab.points3d
any ideas on how want python mayavi? there python 3d plotting package want?
suppose named object :
mypoints = mlab.points3d(...)
you can access @ stage current traits :
mypoint_data = mypoints.mlab_source.get(['points'])['points']
and add whatever want (e.g.: want add point 0,0,1:
mypoint_data = np.vstack((mypoint_data, np.array([[0,0,1]]))) mypoints.mlab_source.set(points=mypoint_data)
if have scalars need updated using keyword 'scalars'
myscalar_data = mypoints.mlab_source.get(['points'])['points'] ... mypoints.mlab_source.set(myscalar_data)
hope helps, , works.
Comments
Post a Comment