Geoscatter plot with different colors
23 views (last 30 days)
Show older comments
Hi everyone!
I am trying to do some plotting wit geographical data.
So I've got Latitude and Longitude, which I want to plot on a map; the third data is a dataset consistion of 0s and 3s. (All Arrays have the same length) So always when its a 3 it sould be green and always when its 0 it should be red.
Could you please help me.
My first try was this:
LockNo = find(Lock == 0)
LockFull = find(Lock==3)
plot(x(LockNo),y(LockNo),'r.',x(LockFull),y(LockFull),'g.');
Thank you in advance!
0 Comments
Answers (1)
Walter Roberson
on 3 Aug 2021
dot_color = repmat([1 0 0], length(Lock), 1);
dot_color(Lock == 3, :) = [0 0 1];
lat = y; long = x;
pointsize = 20;
scatterm(lat, long, pointsize, dot_color)
or
cmap = [1 0 0; 0 0 0; 0 0 0; 0 0 1];
lat = y; long = x;
pointsize = 20;
scatterm(lat, long, pointsize, cmap(Lock+1,:));
0 Comments
See Also
Categories
Find more on Geographic Plots 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!