Learn R Programming

cooltools (version 2.4)

wavelength2col: Convert wavelength to RGB

Description

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

Usage

wavelength2col(wavelength)

Value

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

Arguments

wavelength

wavelength value (or vector), in nanometers.

Author

Danail Obreschkow

Examples

Run this code
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)

Run the code above in your browser using DataLab