plot3js {r3js}R Documentation

3D scatter / line plot

Description

A high level method for generating a 3D scatter or line plot.

Usage

plot3js(
  x,
  y,
  z,
  xlim = NULL,
  ylim = NULL,
  zlim = NULL,
  xlab = NULL,
  ylab = NULL,
  zlab = NULL,
  label = NULL,
  type = "points",
  geometry = NULL,
  axislabel_line = 3,
  aspect = NULL,
  label_axes = c("x", "y", "z"),
  draw_box = TRUE,
  draw_grid = TRUE,
  grid_lwd = 1,
  grid_col = "grey90",
  axis_lwd = grid_lwd,
  box_lwd = grid_lwd,
  box_col = grid_col,
  background = "#ffffff",
  ...
)

Arguments

x

x coords for points / lines

y

y coords for points / lines

z

z coords for points / lines

xlim

plot x limits

ylim

plot y limits

zlim

plot z limits

xlab

x axis label

ylab

y axis label

zlab

z axis label

label

optional vector of interactive point labels

type

one of "points" or "lines"

geometry

should points and lines be represented as physical geometries? Default for points is TRUE and for lines is FALSE, see points() and lines() for more information.

axislabel_line

Distance of axis label from plot

aspect

Plot axis aspect ratio, see plot3js.window()

label_axes

Vector of axes to label, any combination of "x", "y" and "z"

draw_box

Should a box be drawn around the plot

draw_grid

Should an axis grid be drawn in the background

grid_lwd

Grid line width

grid_col

Grid line color

axis_lwd

Axis line width

box_lwd

Box line width

box_col

Box color

background

Background color for the plot

...

Further parameters to pass to material3js()

Value

Returns a data3js object, that can be plotted as a widget using print() or r3js() or further added to with the other plotting functions.

Examples


# Simple plot example
p <- plot3js(
  x = iris$Sepal.Length,
  y = iris$Sepal.Width,
  z = iris$Petal.Length,
  col = rainbow(3)[iris$Species],
  xlab = "Sepal Length",
  ylab = "Sepal Width",
  zlab = "Petal Length"
)

r3js(p, zoom = 2)

# Plotting with point rollover info and highlighting
p <- plot3js(
  x = USJudgeRatings$CONT,
  y = USJudgeRatings$INTG,
  z = USJudgeRatings$DMNR,
  highlight = list(
    col = "darkgreen",
    size = 2.5
  ),
  xlab = "CONT",
  ylab = "INTG",
  zlab = "DMNR",
  size = 2,
  col = "green",
  label = rownames(USJudgeRatings)
)

r3js(p, zoom = 2)


[Package r3js version 0.0.2 Index]