getcolors2: Select colors visually

View source: R/getcolors2.R

getcolors2R Documentation

Select colors visually

Description

The getcolors2 function allows one to select from a visual palette of 1200 colors (i.e. color combinations from 6 levels of red, green, and blue).

Usage

getcolors2(n)

Arguments

n

Numeric value of the number of colors to select

Value

A vector of hexadecimal codings for colors (as in rgb).

Examples

if(interactive()){
# Make synthetic data
set.seed(1)
n <- 100
x <- seq(n)
y1 <- cumsum(rnorm(n))
y2 <- cumsum(rnorm(n))
y3 <- cumsum(rnorm(n))
y4 <- cumsum(rnorm(n))
ylim <- range(c(y1,y2,y3,y4))

# Select colors
COLS <- getcolors2(4)

# Plot data with selected colors
plot(x, y1, ylim=ylim, t="l", col=COLS[1], lwd=3, ylab="")
lines(x, y2, col=COLS[2], lwd=3)
lines(x, y3, col=COLS[3], lwd=3)
lines(x, y4, col=COLS[4], lwd=3)
legend("topleft", legend=paste("y", 1:4, sep=""), col=COLS, lwd=3)
}


marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.