Skip to contents

Create interactive scalable scatterplot using regl-scatterplot JavaScript library.

Usage

rscatter(
  x,
  y,
  size = NULL,
  color = NULL,
  opacity = NULL,
  colorBy = NULL,
  data = NULL,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

x

numeric vector of x coordinates, OR column name for x in data

y

numeric vector of y coordinates, OR column name for y in data

size

point size

color

point color, pass named color vector to map colors to categories

opacity

point opacity, if not specified the opacity will vary with point density and zoom level

colorBy

factor/chr/numeric vector to colorBy, OR column name for colorBy in data

data

optional data.frame containing data to plot

width

fixed width of canvas in pixels (default is resizable)

height

fixed height of canvas in pixels (default is resizable)

elementId

specify id for containing div

Details

For categorical color encoding ensure the colorBy values are factor or character vectors.

Examples

data(quakes)
rscatter(quakes$long, quakes$lat, size = 10, colorBy = quakes$depth)
# Or pass data.frame phi = seq(from = 0, to = 50, by = 1e-2) fermat_spiral = data.frame( x = c(-sqrt(phi)*cos(phi), sqrt(phi)*cos(phi)), y = c(-sqrt(phi)*sin(phi), sqrt(phi)*sin(phi)), branch = rep(c("a", "b"), each = length(phi)) ) rscatter("x", "y", size = 1.5, colorBy = "branch", data = fermat_spiral)