Navigation

Operators and Keywords

Function List:

C++ API

: trimesh (tri, x, y, z, c)
: trimesh (tri, x, y, z)
: trimesh (tri, x, y)
: trimesh (…, prop, val, …)
: h = trimesh (…)

Plot a 3-D triangular wireframe mesh.

In contrast to mesh, which plots a mesh using rectangles, trimesh plots the mesh using triangles.

tri is typically the output of a Delaunay triangulation over the grid of x, y. Every row of tri represents one triangle and contains three indices into [x, y] which are the vertices of the triangles in the x-y plane. z determines the height above the plane of each vertex. If no z input is given then the triangles are plotted as a 2-D figure.

The color of the trimesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.

Optionally, the color of the mesh can be specified independently of z by supplying a color matrix, c. If z has N elements, then c should be an Nx1 vector for colormap data or an Nx3 matrix for RGB data.

Any property/value pairs are passed directly to the underlying patch object.

The optional return value h is a graphics handle to the created patch object.

See also: mesh, tetramesh, triplot, trisurf, delaunay, patch, hidden.

Demonstration 1

The following code

 clf;
 colormap ("default");
 old_state = rand ("state");
 restore_state = onCleanup (@() rand ("state", old_state));
 rand ("state", 10);
 N = 10;
 x = 3 - 6 * rand (N, N);
 y = 3 - 6 * rand (N, N);
 z = peaks (x, y);
 tri = delaunay (x(:), y(:));
 trimesh (tri, x(:), y(:), z(:));

Produces the following figure

Figure 1

Package: octave