I am using the MayaVi Python library to plot 3d points, using the points3d
class. The documentation specifies that the colour of each point is specified through a fourth argument, s
:
In addition, you can pass a fourth array s of the same shape as x, y, and z giving an associated scalar value for each point, or a function f(x, y, z) returning the scalar value. This scalar value can be used to modulate the color and the size of the points.
This specifies a scalar value for each point, which maps the point to a colourmap, such as copper
, jet
or hsv
. E.g. from their documentation:
import numpy
from mayavi.mlab import *
def test_points3d():
t = numpy.linspace(0, 4*numpy.pi, 20)
cos = numpy.cos
sin = numpy.sin
x = sin(2*t)
y = cos(t)
z = cos(2*t)
s = 2+sin(t)
return points3d(x, y, z, s, colormap="copper", scale_factor=.25)
Gives:
Instead, I would like to specify the actual value for each point as an (r, g, b) tuple. Is this possible in MayaVi? I have tried replacing the s
with an array of tuples, but an error is thrown.
This can now simply be done with the
color
argument