2D line plot with colormap

36 views (last 30 days)
Marco Fellous Asiani
Marco Fellous Asiani on 31 May 2016
Answered: Walter Roberson on 31 May 2016
I would like to print a 2D curve (so a line in the plane X,Y) with its colourmap.
I have done this :
figure('Name', name);
plot3(X,Y,squeeze(Z));
view(2)
But I would like to add a colourmap just like I do with surf :
figure('Name', name);
surf(X,Y,squeeze(Z));
colorbar;
shading interp;
view(2);
How to do that ?
Thanks !

Answers (1)

Walter Roberson
Walter Roberson on 31 May 2016
plot() and plot3() do not use colormaps . They use ColorOrder property of the axes. Each line object that is drawn by plot() or plot3() is a single color that by default is chosen from a pre-determined list according to the order it is drawn, not according to the Z coordinate. It is not possible to use plot() or plot3() to have the line colored by Z coordinate.

Categories

Find more on Colormaps in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!