Skip to contents

Splits the active rgl device into two subscenes (the main plot and a legend) and draws, in the legend subscene, in the legend subscene, a colored categorical legend together with its corresponding labels.

Usage

fplot3d(
  labels,
  col = hcld.colors(length(labels)),
  legend.zoom = 0.6,
  legend.width = 0.1,
  legend.mar = 0.2,
  legend.lab = NULL,
  lab.dist = 2.5,
  lab.rev = FALSE,
  ...
)

Arguments

labels

vector with the legend labels (one level per category). Defaults to seq_along(col).

col

vector of colors associated with each label (defaults to hcld.colors(length(labels))).

legend.zoom

zoom factor applied to the legend subscene/panel

legend.width

relative size of the legend spheres, as a fraction of the corresponding dimension of the legend subscene.

legend.mar

relative width of the legend panel, as a fraction of the total device width.

legend.lab

legend title.

lab.dist

distance between the spheres and their text labels.

lab.rev

logical; if TRUE the order of the levels in the legend is reversed (by default they are shown from top to bottom).

...

additional arguments passed to axis3().

Value

Invisibly returns the identifiers of the created subscenes (see rgl::layout3d()).

Examples

library(rgl)
open3d()
# Plot equivalent to fpoints():
f <- as.factor(mtcars$cyl)
fplot3d(levels(f), legend.lab = "cyl")
with( mtcars, plot3d(hp, qsec, mpg, type = "s", col = fcolor(f)))