getcolors2 | R Documentation |
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).
getcolors2(n)
n |
Numeric value of the number of colors to select |
A vector of hexadecimal codings for colors
(as in rgb
).
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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.