Geoscatter plot with different colors
조회 수: 35 (최근 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!