While Marc Ransom and Franco Callari are absolutely right that you cannot reconstruct the perceptual color spectrum or unambiguously display the hue values of the wavelength, you could definitely put something together if you only want the corresponding monochromatic wavelength.
Part of the hue cycle between 270 and 360 is another problem. There is nothing suitable for magenta in the light spectrum, so suppose we use only hue values from 0 to 270.
Estimating that the used part of the visible spectrum is 450-620 nm, with a wavelength of L (in nm) and a hue value of H (in degrees), you can improvise:
L = 620 - 170 / 270 * H
620 is the maximum wavelength, 170 is the wavelength range, and 270 is the range of shades.
I think it should be in the right direction, but I checked only 4 or 5 colors. You can get better results by comparing the input hues and the corresponding colors on the visible spectrum diagram , and then change the values a little.
Junuxx
source share