I want to visualize a scalar function of two variables. Should I use RGB values corresponding to the colours of the rainbow?
When you look at a rainbow you do not see a smooth gradation of colours. Instead, some bands appear quite narrow, and others are quite broad. Perceptibility of hue variation near 540 nm is half that of either 500 nm or 600 nm. If you use the rainbow’s colours to represent data, the visibility of differences among your data values will depend on where they lie in the spectrum. If you are using colour to aid in the visual detection of patterns, you should use colours chosen according to the principles of perceptual uniformity. This an open research problem, but basing your system on CIE L*a*b* or L*u*v*, or on nonlinear video-like RGB, would be a good start.