Learn R Programming

colorRamps (version 2.3.4)

primary.colors: generates expanded sets of primary colors

Description

Combines red, green and blue values to create primary colors

Usage

primary.colors(n, steps = 3, no.white = TRUE)

Value

An R color palette

Arguments

n

number of colors to generate (optional)

steps

number of rgb intensity levels

no.white

boolean indicating whether to return white

Author

Timothy H. Keitt

Details

The standard R palette only provides 8 colors after which colors are recycled. If you need a few more colors that are redily distinguished in multivariate plots, this function can help.

References

Keitt, T. H. (2008) Coherent ecological dynamics induced by large scale disturbance. Nature 454:331-334

Examples

Run this code
x <- matrix(rnorm(100), 10)
x <- sapply(1:10, function(i, x) cumsum(x[,i]), x=x)
par(mfrow = c(1, 2))
matplot(1:10, x, type = 'l', lty = 1, lwd = 3)
matplot(1:10, x, type = 'l', lty = 1, lwd = 3, col = primary.colors(10))

Run the code above in your browser using DataLab