2D line plot with colormap
36 views (last 30 days)
Show older comments
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 !
0 Comments
Answers (1)
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.
If you want colored lines then see for example http://www.mathworks.com/matlabcentral/answers/285872-shading-with-plot3#answer_223465
0 Comments
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!