Plot a 3-D surface mesh.
The surface mesh is plotted using shaded rectangles. The vertices of the
rectangles [x, y] are typically the output of meshgrid
.
over a 2-D rectangular region in the x-y plane. z determines the
height above the plane of each vertex. If only a single z matrix is
given, then it is plotted over the meshgrid
x = 1:columns (z), y = 1:rows (z)
.
Thus, columns of z correspond to different x values and rows
of z correspond to different y values.
The color of the surface 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 surface can be specified independently of z by supplying a color matrix, c.
Any property/value pairs are passed directly to the underlying surface object.
If the first argument hax is an axes handle, then plot into this axis,
rather than the current axes returned by gca
.
The optional return value h is a graphics handle to the created surface object.
Note: The exact appearance of the surface can be controlled with the
shading
command or by using set
to control surface object
properties.
See also: ezsurf, surfc, surfl, surfnorm, trisurf, contour, mesh, surface, meshgrid, hidden, shading, colormap, caxis.
The following code
clf; colormap ("default"); Z = peaks (); surf (Z); title ({"surf() plot of peaks() function"; "color determined by height Z"});
Produces the following figure
Figure 1 |
---|
The following code
clf; colormap ("default"); Z = sombrero (); [Fx,Fy] = gradient (Z); surf (Z, Fx+Fy); shading interp; title ({"surf() plot of peaks() function"; ... "facecolor is interpolated, color determined by gradient of Z"});
Produces the following figure
Figure 1 |
---|
The following code
clf; colormap ("default"); [X,Y,Z] = sombrero (); [~,Fy] = gradient (Z); surf (X, Y, Z, Fy); shading interp; title ({"surf() plot of peaks() function"; ... "facecolor is interpolated, color determined by Y-gradient of Z"});
Produces the following figure
Figure 1 |
---|
Package: octave