How can I connect two points on the world map with an arrow pointing at one end?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
To calarify, I am trying to create a graph projected on the world map. Therefore my secondary objective is to show the direction of the flows using arrows for each edge.
The code:
I am plotting the world map using:
figure;
worldmap('World')
load coastlines %#ok<LOAD>
plotm(coastlat,coastlon)
Next, I am adding the two points using scatterm:
ln = [30 -30]; % longitudes of points
lt = [0 0]; % latitudes
scatterm(ln,lt,'filled','red')
Finally, connecting the points with a geodesic line (great circle):
[l,g] = gcwaypts(ln(1),lt(1),ln(2),lt(2),20);
geoshow(l,g,'displaytype','line','color',[.5 0 .5],...
'markeredgecolor','r','marker','none');
0 Kommentare
Antworten (1)
darova
am 27 Jul. 2019
I'd draw it manually if the line is vertical or horizontal:
x = [2 2];
y = [0 -4]; % line
plot(x,y)
hold on
plot([0 1]+x(2),[0 1]+y(2))
plot([0 -1]+x(2),[0 1]+y(2))
hold off
3 Kommentare
Siehe auch
Kategorien
Mehr zu Map Display finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!