col: Flexible quantitative color schemes

colR Documentation

Flexible quantitative color schemes

Description

col.base is the base for all other functions and allows full flexibility in defining arbitrary quantitative color schemes.

col.bbr provides blue-black-red diverging color scheme (suitable for text and borderless glyphs on white background).

col.bwr provides blue-white-red diverging color scheme (suitable for maps and gryphs with borders).

col.br provides blue-red color scheme.

col.bw provides black-white color scheme.

col.q returns transformed quantity between 0 and 1 for each datapoint (suitable for pass-though to other color schemes). gray(col.q(...)) has the same effect (except for lack of alpha support) as col.bw.

Usage

col.base(x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA, FN)
col.bbr (x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA)
col.bwr (x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA)
col.br  (x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA)
col.bw  (x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA)
col.q   (x, alpha=1, lim=c(0, 1), center = mean(lim), fit=FALSE,
         trans="id", na.col=NA)

Arguments

x

data values (treated as numeric vector).

alpha

alpha value. It will be passed directly to the call to rgb except for col.q where is used to multiply the resulting value.

lim

data cut-off limits (range). Values outside this range will be clipped to the nearest value in the range.

center

center of the scale (mostly useful to calibrate center color of diverging scales).

fit

if set to TRUE then the data is shifted and scaled to fit the entire lim range.

trans

transformation of the resulting values. It can be either a function or one of the character strings "id", "sin" or "asin". The transformation function may not return values larger than 1 or smaller than 0.

na.col

color (or value when used in col.q) to use for missing values, will be used as-is (e.g., alpha is not applied).

FN

function accepting three arguments (a, b, alpha). a is mapped by a linear function descending from 1 to 0 between lim[1] and center. b is a mapped by the correspondingly increasing function between center and lim[2]. alpha is passed from the original function call.

Value

col.base returns the result of the FN function.

col.q returns a vector of numeric values, all other functions return a vector of colors as created by the rgb function.

Examples

 plot(0:10, rep(0, 11), ylim=c(0,5), cex=3, pch=19, col=col.bbr(0:10, fit=TRUE))
 points(0:10, rep(1,11), cex=3, pch=21, bg=col.br(0:10, fit=TRUE), col=1)
 points(0:10, rep(2,11), cex=3, pch=21, bg=col.bw(0:10, fit=TRUE), col=1)
 points(0:10, rep(3,11), cex=3, pch=21, bg=col.bwr(0:10, fit=TRUE, trans=sqrt),
  col=1)
 points(0:10, rep(4,11), cex=3, pch=21, bg=col.bwr(0:10, fit=TRUE), col=1)
 points(0:10, rep(5,11), cex=3, pch=21, bg=col.bwr(0:10, fit=TRUE,
  trans=function(x) x^2), col=1)

s-u/snippets documentation built on June 29, 2022, 6:42 a.m.