colorQuant: Assign colors to numeric values

Description Usage Arguments Value Author(s) Examples

Description

Associates numeric values with a set of colors.

Usage

1
2
colorQuant(x, breaks, colors, lower = TRUE, warn = TRUE,
  NAcolor = "transparent")

Arguments

x

Numeric vector.

breaks

Break points for the colors. In the absence of more suitable information, quantiles of x are often appropriate.

colors

Vector of colors corresponding to breaks.

lower

If TRUE, the data in breaks are interpreted as lower boundaries of color intervals (thus the last element of colors is ignored unless max(x) equals max(breaks)). If TRUE, the data in breaks are interpreted as upper interval boundaries (thus the first element of colors is ignored unless min(x) equals min(breaks)).

warn

Warn if x contains values outside range(breaks)?

NAcolor

Color assigned to NA values in x.

Value

A vector of colors of the same length as x.

Author(s)

David Kneis david.kneis@tu-dresden.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x= runif(10)
x[3]= NA
x[5]= 2
breaks= c(0, .33, 0.66, 1)
colors= colorRampPalette(c("steelblue2","khaki2","brown"))(length(breaks))
low=FALSE
barplot(height=x, names.arg=1:length(x), ylim=c(0,1.2),
  col=colorQuant(x, breaks, colors, low))
abline(h=breaks, lty=3)
legend("top", bty="n", horiz=TRUE, fill=colorQuant(breaks, breaks, colors, low),
  legend=paste(ifelse(low, ">", "<"),breaks))

dkneis/diatools documentation built on May 15, 2019, 9:12 a.m.