inst/doc/getting-started.R

## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(r3js)

## ---- out.width="100%", out.height="400px"------------------------------------
# Generate and view a simple 3D scatterplot
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x, y)
  
p <- plot3js(x, y, z, col = rainbow(1000))
r3js(p)

## ---- out.width="100%", out.height="400px"------------------------------------
p <- plot3js(
  x = runif(100),
  y = runif(100),
  z = runif(100),
  size = 3,
  col = rainbow(100),
  label = paste("Point", 1:100),
)

r3js(p)

## ---- out.width="100%", out.height="400px"------------------------------------
p <- plot3js(
  x = runif(100),
  y = runif(100),
  z = runif(100),
  size = 3,
  col = rainbow(100),
  highlight = list(
    size = 4,
    col = rev(rainbow(100)),
    mat = "basic"
  ),
  interactive = TRUE
)

r3js(p)

## ---- out.width="100%", out.height="400px"------------------------------------
x <- runif(100)
y <- runif(100)
z <- runif(100)

col <- c(
  rep("blue", 50),
  rep("red", 50)
)

toggle <- paste(col, "points")

p <- plot3js(
  x = x,
  y = y,
  z = z,
  size = 3,
  col = col,
  toggle = toggle
)

r3js(p)

Try the r3js package in your browser

Any scripts or data that you put into this service are public.

r3js documentation built on March 31, 2023, 7:23 p.m.