The "function"
method for plot3d
simply passes
all arguments to persp3d
. Thus this description applies
to both.
The first argument x
is required to be a function. It
is named x
only because of the requirements of the S3
system; in the remainder of this help page, we will assume
that the assignment f <- x
has been made, and will
refer to the function f()
.
persp3d.function
evaluates f()
on a two-dimensional
grid of values, and displays the resulting surface. The values
on the grid will be passed in as vectors in the
first two arguments to the function, so f()
needs
to be vectorized. Other optional arguments to f()
can be specified in the otherargs
list.
In the default form where slim
and tlim
are both
NULL
, it is assumed that f(x, y)
returns heights,
which will be plotted in the z coordinate. The default axis labels
will be taken from the argument names to f()
and the
expression passed as argument x
to this function.
If slim
or tlim
is specified, a parametric
surface is plotted. The function
f(s, t)
must return a 3-column matrix, giving x, y and z
coordinates of points on the surface. The default axis
labels will be the column names if those are present.
In this case xlim
, ylim
and zlim
are used to define a clipping region only if specified;
the defaults are ignored.
The color of the surface may be specified as the name of a
color, or a vector or matrix of color names. In this case
the colors will be recycled across the points on the grid
of values.
Alternatively, a function may be given: it should be a function
like rainbow
that takes an integer argument and
returns a vector of colors. In this case the colors are mapped
to z values.
The normal
argument allows specification of a function
to compute normal vectors to the surface. This function is
passed the same arguments as f()
(incuding otherargs
if present), and should produce a 3-column matrix containing the
x, y and z coordinates of the normals.
The texcoords
argument is a function similar to normal
, but
it produces a 2-column matrix containing texture coordinates.
Both normal
and texcoords
may also contain matrices,
with 3 and 2 columns respectively, and rows corresponding to the
points that were passed to f()
.