rygcb | R Documentation |
Produces a rainbow color palette with colors ranging from
"red"
to "blue"
or "magenta"
.
Perceptual uniformity should be superior to R's rainbow
.
rygcb(n)
rygcbm(n)
n |
Number of color levels |
The palette is created using colorRampPalette
.
A vector of colors.
The call to colorRampPalette
sets space="Lab"
and interpolate="spline"
with the intent of creating
a more perceptually uniform rainbow.
M.L. Peck
grey256
plotsp <- function(spectrum) {
sl <- length(spectrum)
rgbv <- col2rgb(spectrum)
plot((0:(sl-1))+0.5, rgbv[1,], type="l", col="red", xlim=c(0,sl),ylim=c(0,300),xlab="Index",ylab="Channel value")
points((0:(sl-1))+0.5, rgbv[2,], type="l", col="green")
points((0:(sl-1))+0.5, rgbv[3,], type="l", col="blue")
grid()
rect(0:(sl-1), 260, 1:sl, 300, col=spectrum, density=NA)
}
plotsp(rygcb(400))
X11()
plotsp(rygcbm(500))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.