Using z values to display color in mapping toolbox?

12 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2016-10-28
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.
  2 个评论
Kate
Kate 2016-10-28
Perfect Walter, scatterm should do the trick, thanks a bunch!
Kate
Kate 2016-10-28
Perfect fix Walter, can't thank you enough, scatterm is great!
<<
>>

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by