cont2color

0th

Percentile

Assign colours to numeric vector

This function assigns colours on a linear scale to a numeric vector. Default is to try to use RColorBrewer for colours, and cm.colors otherwise. Can provide custom range, breaks and colours.

Usage
cont2color(x, xrange = NULL, breaks = NULL, colors = NULL)
Arguments
x

A numeric vector.

xrange

The range to use for the colour scale.

breaks

The number of breaks at which to change colour.

colors

The colours to use. Defaults to a diverging colour scheme; either "PiYG" from RColorBrewer if available, or cm.colors otherwise.

Details

Uses the RColorBrewer package if installed. Coerces x to numeric with a warning.

Value

A character vector of colours.

See Also

factor2color

Aliases
  • cont2color
Examples
# NOT RUN {
x <- runif(200)
plot(x, col = cont2color(x, c(0,1)))

plot(x, col = cont2color(x, c(0,0.5)))

plot(sort(x), col = cont2color(sort(x), c(0.25,0.75)), pch = 16)
abline(h = c(0.25, 0.75), lty = 3)

# }
Documentation reproduced from package condvis, version 0.5-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.