Using z values to display color in mapping toolbox?
12 views (last 30 days)
Show older comments
Apologies, I'm new to the mapping toolbox.
I have coordinates with associated z values that I would like to use to display color using a colormap such as redblue. However, when I feed the mapping toolbox the information all points are the same color.
h=plotm(Latitude, Longitude, z, '.', 'MarkerSize', 20)
I've checked and points do have z values (see figure). I'm sure it's an easy fix but haven't been able to find the solution anywhere. How do I use z values to display color?
Thanks a million, Kate
0 Comments
Accepted Answer
Walter Roberson
on 28 Oct 2016
plotm() is not documented as accepting z values. However, it does not do error checking on any argument after the first 2 and instead just passes everything after the lat and long arguments to linem() . linem() is documented as accepting z.
If you want to pass in z, you should be using plot3m() instead of plotm()
However, neither plotm() nor plot3m() will color the line by depth. Both of them use linem() internally, and linem() uses line() internally, and any one line is restricted to being a single color.
You appear to be displaying points rather than lines. You should be using scatterm() for displaying points. scatterm accepts a color argument (lat, long, size, color) which can be set to either a matrix of RGB triples (to give exact colors for each point) or to a vector that interacts with caxis() to determine color scaling. The default for caxis is to draw the minimum value as the first color in the colormap and the maximum value as the last color in the color map and to scale linearly in-between.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!