3D Plotting functions for numpy arrays¶
Visualization can be created in mlab by a set of functions operating on numpy arrays.
The mlab plotting functions take numpy arrays as input, describing the
x
, y
, and z
coordinates of the data. They build full-blown
visualizations: they create the data source, filters if necessary, and
add the visualization modules. Their behavior, and thus the visualization
created, can be fine-tuned through keyword arguments, similarly to pylab.
In addition, they all return the visualization module created, thus
visualization can also be modified by changing the attributes of this
module.
Note
In this section, we only list the different functions. Each function is described in detail in the MLab reference, at the end of the user guide, with figures and examples. Please follow the links.
0D and 1D data¶
2D data¶
Vertical scale of surf()
and contour_surf()
surf()
and contour_surf()
can be used as 3D
representation of 2D data. By default the z-axis is supposed to
be in the same units as the x and y axis, but it can be
auto-scaled to give a 2/3 aspect ratio. This behavior can be
controlled by specifying the “warp_scale=’auto’”.
From data points to surfaces.
Knowing the positions of data points is not enough to define a
surface, connectivity information is also required. With the
functions surf()
and mesh()
, this connectivity
information is implicitly extracted from the shape of the input
arrays: neighboring data points in the 2D input arrays are
connected, and the data lies on a grid. With the function
triangular_mesh()
, connectivity is explicitly specified.
Quite often, the connectivity is not regular, but is not known in
advance either. The data points lie on a surface, and we want to
plot the surface implicitly defined. The delaunay2d filter does
the required nearest-neighbor matching, and interpolation, as
shown in the (Surface from irregular data example).
3D data¶
Structured or unstructured data
contour3d()
and flow()
require ordered data (to
be able to interpolate between the points), whereas quiver3d()
works with any set of points. The required structure is detailed
in the functions’ documentation.
Note
Many richer visualizations can be created by assembling data sources filters and modules. See the Assembling pipelines with mlab and the Case studies of some visualizations sections.