3
votes

I have a plot in Matlab that shows the intensity as a function of the wavelength (in nm) :

example

enter image description here

I wonder if there is an easy way to color the plot according to the wavelength like this.

enter image description here

1
It can be done, but I don’t think there’s an easy way. - Cris Luengo
I am surprised, but I could not find anything at matlab file exchange. - Daniel

1 Answers

1
votes

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

enter image description here