Learn R Programming

fifer (version 1.1)

number.to.colors: Convert from numbers to colors

Description

Automatically convert a vector of numbers into a color for easy plotting

Usage

number.to.colors(value, colors = c("red", "blue"), num = 100)

Arguments

value
a vector of numbers.
colors
a vector of two or more colors representing the inflection points of the gradients, passed to colorRampPalette.
num
The number of unique intervals for colors. Chose larger numbers for finer gradients (higher resolution).

Value

a vector of colors.

See Also

string.to.colors colorRampPalette gradient.legend

Examples

Run this code
#### plot three variables, represent the third with a color
d = mvrnorm(100, mu=c(0,0,0), Sigma=matrix(c(1, .6, .6, .6, 1, .6, .6, .6, 1), ncol=3))
plot(d[,1:2], col=number.to.colors(d[,3], c("black", "pink")), pch=16)

Run the code above in your browser using DataLab