How can I assign labels to my geo scatter plot?

조회 수: 100 (최근 30일)
Paula Moehlenkamp
Paula Moehlenkamp 2019년 10월 12일
답변: Samatha Aleti 2019년 10월 17일
I made a geoscatter plot using the following code:
geoscatter(Lat,Long,'r', 'filled')
Lat and Long are numerical vectors. My matrix has another column with SiteLabels. How do I assign each dot on my geoscatter plot a Label?

답변 (1개)

Samatha Aleti
Samatha Aleti 2019년 10월 17일
You can apply different data labels to each point on “geoscatter” plot by using the “text” command. The command “text” takes the plot data as input. Following is a sample code:
% geoscatter plot
lon = (-170:10:170);
lat = 50 * cosd(3*lon);
A = 101 + 100*(sind(2*lon));
C = cosd(4*lon);
geoscatter(lat,lon,A,C,'^')
% label
a = [1:35]';
b = num2str(a); c = cellstr(b); % strings to label
dx = 0.1; dy = 0.1; % displacement so the text does not overlay the data points
text(lat+dx, lon+dy, c);
Refer the following documentation link for more details on “text”:

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by