arrows3js: Add arrows to a data3js object

View source: R/3JSobjects.R

arrows3jsR Documentation

Add arrows to a data3js object

Description

Add arrows to a data3js object

Usage

arrows3js(
  data3js,
  from,
  to,
  lwd = 1,
  arrowhead_width = 0.2,
  arrowhead_length = 0.5,
  col = "black",
  mat = "lambert",
  ...
)

Arguments

data3js

The data3js object

from

nx3 matrix of coords for the arrow start points

to

nx3 matrix of coords for the arrow end points

lwd

line width

arrowhead_width

arrowhead width

arrowhead_length

arrowhead length

col

color

mat

material (see material3js())

...

other arguments to pass to material3js()

Value

Returns an updated data3js object

See Also

Other plot components: axis3js(), box3js(), grid3js(), legend3js(), light3js(), lines3js(), mtext3js(), points3js(), segments3js(), shape3js(), sphere3js(), surface3js(), text3js(), triangle3js()

Examples

# Draw a set of arrows
from <- cbind(
  runif(10, 0.2, 0.8),
  runif(10, 0.2, 0.8),
  runif(10, 0.2, 0.8)
)

to <- jitter(from, amount = 0.2)

# Setup base plot
p <- plot3js(label_axes = FALSE)

# Add arrows
p <- arrows3js(
  p, from, to,
  arrowhead_length = 0.06,
  arrowhead_width = 0.04,
  lwd = 0.01
)

# View the plot
r3js(p, translation = c(0, 0, 0.15), zoom = 2)


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