How label data points using text within a for loop
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to produce a map of tide gauges using Geoscatter and then label each tide gauge with its corresponding tide gauge number. I have an array, A, that contains 58 tide guages - each one with it's own tide gauge number. I also have arrays for longitude and latitude that corresponds to each tide gauge number. So far, I have got this:
load('A.mat');
load('PSMSL+ERA5IB.mat');
geoscatter(Latitude(A),Longitude(A),20)
for i=1:58
text(Longitude(A(i)),Latitude(A(i)),string(A(i)));
end
This produces a map, but doesn't give the labels for the tide gauges. I'm not sure why
0 Kommentare
Antworten (1)
Eric Delgado
am 22 Mär. 2023
It seems that you have to create a custom data tips...
rawData = table([-13;-30], [-39; -39], ["ID 1"; "ID 2"], 'VariableNames', {'lat', 'long', 'label'})
figure
h = geoscatter(rawData.lat, rawData.long);
h.DataTipTemplate.DataTipRows(end+1) = dataTipTextRow('Label', rawData.label);
datatip(h, -13, -39);
datatip(h, -30, -39);
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!