I have a plot in Matlab that shows the intensity as a function of the wavelength (in nm) :
example
I wonder if there is an easy way to color the plot according to the wavelength like this.
I have a plot in Matlab that shows the intensity as a function of the wavelength (in nm) :
example
I wonder if there is an easy way to color the plot according to the wavelength like this.
This is the closest I could come up with using only a few lines of code. The colors are probably not precisely matched to the wavelengths, but you should be able to fine tune them by playing with the third (color) argument of the patch command.
x = 350:900;
y = ((x-650).^2)/4000 + 10 + 5*rand(size(x));
patch([x(1) x x(end)], [0 y 0], [0 0 5*(1:numel(x))], 'FaceColor', 'interp')
colormap jet