Geoscatter plot with different colors
36 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2021-8-3
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Geographic Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!