搬运自How to directly set RGB/RGBA colors in mayavi
以下是我实现的代码:
colors = pts[:, 3:6]
colors_with_alpha = np.hstack((colors, 255*np.ones((colors.shape[0], 1))))
sc=tvtk.UnsignedCharArray()
sc.from_array(colors_with_alpha)
G = mlab.points3d(pts[:, 0], pts[:, 1], pts[:, 2], mode='point',
scale_factor=1, figure=fig)
G.mlab_source.dataset.point_data.scalars=sc
G.mlab_source.dataset.modified()