surfl
Surface plot with colormap-based lighting
Syntax
Description
surfl(
creates a three-dimensional surface plot with highlights from a light source.
The function plots the values in matrix X
,Y
,Z
)Z
as heights above a
grid in the x-y plane defined by
X
and Y
. The function uses the default
direction for the light source and the default lighting coefficients for the
shading model. This sets the color data for the surface to be the reflectance of
the surface.
Because of the way surface-normal vectors are computed,
surfl
requires matrices that are at least 3-by-3.
surfl(
creates a surface and uses
the column and row indices of the elements in Z
)Z
as the
x- and y-coordinates.
surfl(___,'light')
creates a surface with
highlights from a MATLAB® light object. This produces different results from the default
colormap-based lighting method. Specify the 'light'
object as
the last input argument.
surfl(___,
sets properties of the surface plot using one or more name-value arguments. For
example, you can set the color and transparency of the surface. For a list of
properties, see Surface Properties. (since R2024b)Name=Value
)
surfl(
plots into
the axes specified by ax
,___)ax
instead of the current axes. Specify
the axes as the first input argument.
s = surfl(___)
returns the chart surface
object. If the light source is specified as a light object using the
'light'
option, then s
is returned as
a graphics array that includes the chart surface object and the light object.
Use s
to modify the surface and light object after it is
created. For a list of properties, see Surface Properties and Light Properties.
Examples
Input Arguments
Tips
The ordering of points in the
X
,Y
, andZ
matrices defines the inside and outside of parametric surfaces. To have the opposite side of the surface reflect the light source, usesurfl(X',Y',Z')
.