surfl

Draws a 3-D surface with lighting based on a light source.

Category: Graphics > 2-D and 3-D Plots

Syntax

surfl(Z)

Draws a lit surface with heights Z.

surfl(X, Y, Z)

Uses X and Y as coordinates.

surfl(X, Y, Z, s)

Places the light in direction s, as [azimuth elevation] or [sx sy sz].

Description

The color of each point is computed from the surface normal and the light direction, combining ambient, diffuse and specular terms. It works best with a smooth, monotonic colormap such as gray or copper, together with shading interp.

Input arguments

X, Y, Z
Coordinates, as for surf.
s
Light direction.

Output arguments

h
Handle of the surface.

Example

Lit peaks in gray

[X, Y, Z] = peaks(30);
surfl(X, Y, Z)
shading interp
colormap(gray)

In the app, the figure is drawn below the code.

See also

surf camlight lighting shading colormap