View source: R/parse_wavelength.R
| wavelength | R Documentation |
Convert colors specified as the wavelength of a beam of monochromatic light into an R color.
wavelength(x)
wl(x)
x |
vector of wavelengths. |
The human eye can distinguish colors between approximately 380 and 750 nm. The colors that we name (arbitrarily, since they really change continuously along the spectrum) are: Violet = [380,450] nm, Blue = [450,495] nm, Green = [495,570] nm, Yellow = [570,590] nm, Orange = [590,620] nm, Red = [620,750] nm.
The correspondance with colors in sRGB-space (the ones R can use) is only approximate because not all monochromatic light colors can be accurately represented in sRGB. Technically it is done by interpolating from a lookup table, described in visible, which itself is a numerical approximation of the match between input colours and sRGB equivalents.
A vector of colors specified as hex codes
Other color specifications:
cmyk(),
css(),
hcl(),
hex(),
hsi(),
hsl(),
hsv(),
lab(),
parse_color(),
rgb(),
ryb(),
temperature()
# Display the full visible spectrum
x <- seq(370, 760, length.out=200)
plot(x=x, y=rep(0, 200), col=wavelength(x), pch="|", cex=5)
abline(v=c(380, 450, 495, 570, 590, 620, 750), lty="dotted")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.