wavelength2col: Convert wavelength to RGB

Description Usage Arguments Value Author(s) Source Examples

Description

Converts a given wavelength of light to an approximate RGB color value, using black in the invisible range.

Usage

1
wavelength2col(wavelength)

Arguments

wavelength

wavelength value (or vector), in nanometers.

Value

Returns a color string or vector of color strings with the same number of elements as wavelength.

Author(s)

Danail Obreschkow

Source

Smoothed implementation of the original Fortran version by Dan Bruton (http://www.physics.sfasu.edu/astro/color/spectra.html) and the R-function by Michael Friendly (https://gist.github.com/friendly).

Examples

1
2
3
4
lambda = seq(300,800)
col = matrix(wavelength2col(lambda),nrow=1)
plot(NA,xlim=range(lambda),ylim=c(0,1),xaxs='i',xlab='wavelength [nm]',yaxs='i',yaxt='n',ylab='')
rasterImage(col,min(lambda),0,max(lambda),1)

graphx documentation built on Feb. 3, 2022, 5:07 p.m.