I want to plot different locations on a map of NY state. My current code plots the entirety of North America because I couldn\'t find how to plot just one state. I\'m trying
You can get a USA state map with usamap('New York')
and plot an overlay text with textm
. Here, 25 random points and their label are plotted on the figure.
The following plot
is produced by
latlim = [39 47];
lonlim = [-81 -70];
figure('Color','w');
usamap('New York')
shi = shaperead('usastatehi', 'UseGeoCoords', true,...
'Selector',{@(name) strcmpi(name,'New York'), 'Name'});
geoshow(shi, 'FaceColor', [0.3 1.0, 0.675])
textm(shi.LabelLat, shi.LabelLon, shi.Name, 'HorizontalAlignment', 'center')
nb_point = 25;
LAT = latlim(1) + (latlim(2)-latlim(1)).*rand(nb_point,1);
LON = lonlim(1) + (lonlim(2)-lonlim(1)).*rand(nb_point,1);
h = geoshow(LAT, LON, 'DisplayType', 'Point', 'Marker', '+', 'Color', 'red');
textm(LAT, LON+0.3, num2str((1:nb_point)'), 'FontSize',14)