MATLAB: How do project a curve in the form of a varying color map/box

colorcolormapplot

I have X and Y data (Intensity vs frequency) and I would like to project the curve of varying color (say red for max intensity, blue for min) on to the X axis and then give the projected line some thickness (for the purpose of better visualization). Can anyone help? I hope my question was clear. Thank you.

Best Answer

pcolor(repmat(x(:),1,2)', [zeros(length(x),1),ones(length(x),1)]', repmat(y(:),1,2)')
and then create a colormap that shades between blue and red:
cmap = [linspace(0,1,256)', zeros(256,1), linspace(1,0,256)'];
colormap(cmap);
The drawing task is much easier if the x are at regular intervals:
imagesc(y(:).')