plotBitScatter: Create a bitmap-rendered plot.

View source: R/plotBitScatter.R

plotBitScatterR Documentation

Create a bitmap-rendered plot.

Description

plotBitScatter is a wrapper around plot which renders the plot area as a bitmap (png), but keeps all other elements (axes, labels, etc.) as vector elements. This is especially useful for keeping the size of PDF files with scatter plots with many elements small, while retaining editability of axes.

Usage

plotBitScatter(
  x,
  y = NULL,
  ...,
  densCols = TRUE,
  colpal = c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red",
    "#7F0000"),
  xpixels = 1000,
  ypixels = NULL,
  pointsize = NULL
)

Arguments

x

numeric vector with x-coordinates of points, or a two-column matrix with x- and y- coordinates.

y

numeric vector with y-coordinates of points (same length as x). Can be NULL, in which case x must be a two-column matrix.

...

any further arguments to be passed to plot

densCols

logical(1). If TRUE and col is not given as an additional argument, then the local density of points will be used as colors, using the palette spanned by the colors in colpal.

colpal

vector of colors defining the palette for automatic density-based coloring.

xpixels

the number of pixels in the x dimension used for rendering the plotting area.

ypixels

the number of pixels in the y dimension used for rendering the plotting area. If NULL (the default), will be calculated automatically as xpixels * par('pin')[2] / par('pin')[1], such that the aspect ratio of the current plotting region is observed. This may not work (e.g. when using layout()), as this may result in negative values returned by par('pin'). In that case, ypixels should be set manually using this argument.

pointsize

the size of points used for the png device when rendering the plot. If NULL (the default), will be calculated automatically as 12 / graphics::grconvertX(par("pin")[1], from = "inches", to = "device") * xpixels. This may not work (e.g. when using layout()), as this may result in negative values returned by par('pin'). In that case, pointsize should be set manually using this argument.

Details

xpixels controls the resolution of the rendered plotting area. In order to keep circular plotting symbols circlular (e.g. pch = 1), ypixels is automatically calculated using xpixels and the aspect ratio of the current plotting area. If the plotting device is rescaled after calling plotBitScatter, circular plotting symbols may become skewed.

Value

NULL (invisibly)

Author(s)

Michael Stadler

Examples

x <- rnorm(1000)
y <- rnorm(1000)
par(mfrow=c(1,2))
plotBitScatter(x, y, main = "bitmap")
plot(x, y, main = "default")


fmicompbio/swissknife documentation built on June 11, 2025, 4:17 p.m.