grouped scatter on geographical axes

조회 수: 6 (최근 30일)
Bruno Martinico
Bruno Martinico 2020년 11월 3일
답변: Bruno Martinico 2020년 12월 1일
I need to scatter a points dataset on geographical axes, but I need also to group scatter points so that I can set group properties. In particular for each group I need to set different markerfacecolor and marckeredgecolor.
gscatter function can't be plotted on geoaxes so my figure is deformed, but can have colors that I define.
geoscatter function do not allow grouping scatter points but points are not deformed.
How can I resolve?
I attached an example on a png file.
Thanks for answer.

채택된 답변

Tarunbir Gambhir
Tarunbir Gambhir 2020년 12월 1일
Since the geoscatter function does not support grouping, I suggest you segregate/group the data points manually before plotting. Then use geoscatter to plot every group with their unique properties.

추가 답변 (1개)

Bruno Martinico
Bruno Martinico 2020년 12월 1일
Thankyou! I do not know if it is the less expensive, but I found the following way:
In M_IDPs2 are my points, and it is a (numberofpoints, 3) matrix. Columns: lat, lon, I.
A for loop on "I", that are possible group labels of points stored in M_IDPs2 (I do not know/choose a-priori for points the values of the interval 1:0.5:11 because they are an output of a calculus). I look for points for each "I" with find and only when I find them I store them in M_scatgroup and plot them. fMarkFaceCol(I) and fMarkEdgeCol(I) are external functions I defined to choose proper colors inside the loop iterations.
for I=1:0.5:11
c3=find(M_IDPs2(:,3)==I);
if (~isempty(c3))
M_scatgroup=M_IDPs2(c3,:);
gs=geoscatter(gx,M_scatgroup(:,1),M_scatgroup(:,2),[],[1 0 1],'o');
gs.MarkerFaceColor=fMarkFaceCol(I);
gs.MarkerEdgeColor=fMarkEdgeCol(I);
gs.DisplayName=num2str(I);
hold on
lgd=legend;
lgd.AutoUpdate='on';
end
end

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by