scattermore {scattermore}R Documentation

scattermore

Description

Convert points to raster scatterplot rather quickly.

Usage

scattermore(
  xy,
  size = c(512, 512),
  xlim = c(min(xy[, 1]), max(xy[, 1])),
  ylim = c(min(xy[, 2]), max(xy[, 2])),
  rgba = c(0L, 0L, 0L, 255L),
  cex = 0,
  output.raster = TRUE
)

Arguments

xy

2-column float matrix with point coordinates. As usual with rasters in R, X axis grows right, and Y axis grows DOWN. Flipping ylim causes the usual mathematical behavior.

size

2-element vector integer size of the result raster, defaults to c(512,512).

xlim, ylim

Float limits as usual (position of the first pixel on the left/top, and the last pixel on the right/bottom). You can easily flip the top/bottom to the "usual" mathematical system by flipping the ylim vector.

rgba

4-row matrix with color values of 0-255, or just a single 4-item vector for c(r,g,b,a). Best created with col2rgb(..., alpha=TRUE).

cex

Additional point radius in pixels, 0=single-pixel dots (fastest)

output.raster

Output R-style raster (as.raster)? Default TRUE. Raw array output can be used much faster, e.g. for use with png::writePNG.

Value

Raster with the result.

Examples

library(scattermore)
plot(scattermore(cbind(rnorm(1e6), rnorm(1e6)), rgba = c(64, 128, 192, 10)))

[Package scattermore version 1.2 Index]