This function also enables setting color and opacity, etc. Doc is here,See Plotting functions - contour3d.:
contour3d
mayavi.mlab.contour3d(*args, **kwargs)Plots iso-surfaces for a 3D volume of data supplied as arguments.
Function signatures:
contour3d(scalars, ...) contour3d(x, y, z, scalars, ...)
scalars is a 3D numpy arrays giving the data on a grid.If 4 arrays, (x, y, z, scalars) are passed, the 3 first arrays give the position, and the last the scalar value. The x, y and z arrays are then supposed to have been generated by numpy.mgrid, in other words, they are 3D arrays, with positions lying on a 3D orthogonal and regularly spaced grid with nearest neighbor in space matching nearest neighbor in the array. The function builds a scalar field assuming the points are regularly spaced.
Keyword arguments:
color
the color of the vtk object. Overides the colormap, if any, when specified. This is specified as a triplet of float ranging from 0 to 1, eg (1, 1, 1) for white.
colormap
type of colormap to use.
contours
Integer/list specifying number/list of contours. Specifying a list of values will only give the requested contours asked for.
extent
[xmin, xmax, ymin, ymax, zmin, zmax] Default is the x, y, z arrays extent. Use this to change the extent of the object created.
figure
Figure to populate.
line_width
The width of the lines, if any used. Must be a float. Default: 2.0
name
the name of the vtk object created.
opacity
The overall opacity of the vtk object. Must be a float. Default: 1.0
reset_zoom
Reset the zoom to accomodate the data newly added to the scene. Defaults to True.
transparent
make the opacity of the actor depend on the scalar.
vmax
vmax is used to scale the colormap. If None, the max of the data will be used
vmin
vmin is used to scale the colormap. If None, the min of the data will be usedExample (run in
ipython --gui=qt
, or in the mayavi2 interactive shell, see Running mlab scripts for more info):def test_contour3d(): x, y, z = np.ogrid[-5:5:64j, -5:5:64j, -5:5:64j] scalars = x * x * 0.5 + y * y + z * z * 2.0 obj = contour3d(scalars, contours=4, transparent=True) return obj ```