Main Content

trisurf

Triangular surface plot

Description

example

trisurf(T,x,y,z) plots the 3-D triangular surface defined by the points in vectors x, y, and z, and a triangle connectivity matrix T.

example

trisurf(TO) plots the surface defined by a 3-D triangulation or delaunayTriangulation object.

trisurf(___,c) also specifies the surface color for either of the previous syntaxes.

trisurf(___,Name,Value) specifies one or more properties of the surface plot using name-value pairs. For example, 'FaceColor','y' sets the face color to yellow.

h = trisurf(___) returns a patch object used to create the surface plot. Use h to query and modify properties of the plot. For more information, see Patch Properties.

Examples

collapse all

Create a set of 3-D points and compute the Delaunay triangulation using the delaunay function. Plot the surface defined by the triangulation.

[x,y] = meshgrid(1:15,1:15);
z = peaks(15);
T = delaunay(x,y);
trisurf(T,x,y,z)

Figure contains an axes object. The axes object contains an object of type patch.

Alternatively, you can create and plot a triangulation object.

TO = triangulation(T,x(:),y(:),z(:));
trisurf(TO)

Figure contains an axes object. The axes object contains an object of type patch.

Input Arguments

collapse all

Triangle connectivity, specified as a 3-column matrix where each row contains the point vertices defining a triangle face.

x-coordinates, specified as a column vector.

y-coordinates, specified as a column vector.

z-coordinates, specified as a column vector.

Face color, specified as a matrix of colormap indices the same size as z. For more information, see How Surface Plot Data Relates to a Colormap. For additional control over the surface coloring, use the 'EdgeColor' and 'FaceColor' name-value pairs.

Triangulation object, specified as a triangulation or delaunayTriangulation object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: trisurf(TO,'FaceColor','r')

The properties listed here are only a subset. For a complete list, see Patch Properties.

Face color, specified as the comma-separated pair consisting of 'FaceColor' and a color name, an RGB triplet, or 'none'.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Face transparency, specified as the comma-separated pair consisting of 'FaceAlpha' and a scalar in the range [0,1]. A value of 1 is opaque and 0 is completely transparent. Values between 0 and 1 are semitransparent.

Edge color, specified as the comma-separated pair consisting of 'EdgeColor' and a color name, an RGB triplet, or 'none'. The default color of [0 0 0] corresponds to black boundaries.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. This table lists the long and short color name options and the equivalent RGB triplet values.

Long NameShort NameRGB Triplet
'yellow''y'[1 1 0]
'magenta''m'[1 0 1]
'cyan''c'[0 1 1]
'red''r'[1 0 0]
'green''g'[0 1 0]
'blue''b'[0 0 1]
'white''w'[1 1 1]
'black''k'[0 0 0]

Line width, specified as the comma-separated pair consisting of 'LineWidth' and a positive numeric value in points.

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

"none"No lineNo line

Extended Capabilities

Version History

Introduced before R2006a