A generic function that, by default, draws a 3D scatter plot (rgl::plot3d())
with points colored according to the levels of a factor f, and (optionally)
adds a categorical legend (via fplot3d()).
Usage
fpoints3d(x, ...)
# Default S3 method
fpoints3d(
x,
y = NULL,
z = NULL,
f,
col = hcld.colors(nlevels(f)),
xlab = NULL,
ylab = NULL,
zlab = NULL,
type = "p",
legend = TRUE,
legend.type = c("s", "c", "p", "l"),
legend.zoom = 0.6,
legend.width = 0.2,
legend.size = 4,
legend.dim = 0.2,
legend.lab = NULL,
lab.dist = 2.5,
lab.rev = FALSE,
add = FALSE,
...
)Arguments
- x
object used to select a method. In the default method, it provides the
xcoordinates for the plot (and optionally theyandzcoordinates; any reasonable way of defining the coordinates is acceptable, see the functionxyz.coords()for details).- ...
additional arguments passed to
rgl::plot3d()for the main scatter plot (e.g.size).- y, z
yandzpoint coordinates. Alternatively, a single argumentxcan be provided.- f
(factor, or vector coercible to factor), used to color the points.
- col
vector of colors associated with each level of
f(defaults tohcld.colors(nlevels(f))).- xlab, ylab, zlab
labels for the coordinates.
- type
character indicating the type of item to plot (see
rgl::plot3d():"p"for points,"s"for spheres,"l"for lines,"h"for line segments from z = 0, and"n"for nothing).- legend
logical; if
TRUE(default), the active rgl device is splitted into two subscenes, drawing the main plot in one and the categorical legend in the other (seefplot3d()). ifFALSEonly the (coloured) main plot is drawn and the arguments related to the legend are ignored (fplot3d()is not called).- legend.type
character; symbol/object used to represent each level in the legend (see
typeinfplot3d()):"s"for spheres (default),"c"for cubes,"p"for points, or"l"for (horizontal) line segments.- legend.zoom
zoom factor applied to the legend subscene/panel.
- legend.width
relative size of the legend symbols (spheres, cubes or line segments), as a fraction of the corresponding dimension of the legend subscene.
- legend.size
point size, if
type = "p", or line width, iftype = "l"(in pixels; seesizeandlwdgraphical parameters inrgl::par3d(); ignored in all other cases).- legend.dim
relative dimension of the legend panel, as a fraction of the full width (or height) of the device.
- legend.lab
label for the axis of the color legend, defaults to a description of
f.- lab.dist
distance between the legend symbols and their text labels, as a multiple of the symbol size (
legend.width).- lab.rev
logical; if
TRUEthe order of the levels in the legend is reversed (by default they are shown from top to bottom).- add
logical; if
TRUEthe scatter plot is just added to the existing plot (including the legend iflegend = TRUE).
Value
Called for its side effect (draws the 3D scatter plot and, unless
legend = FALSE, the legend on the active rgl device).