check the 3D color chart and / or color line or scatter plot as from file sharing.
or if you want to do it yourself, you can use surface
:
x=linspace(-10,10,256); y=sin(x); c=1:numel(x); colormap(jet(256)); % or whatever colormap you want surface('XData', [x(:) x(:)],'YData',[y(:) y(:)],... 'ZData',0*[x(:) x(:)],'CData',[c(:) c(:)],'EdgeColor','flat');
Read more about surface
properties here .
source share