Another related question is that once I get the points plotted, I have to know what points they are. If I have the names in a separate cell array, how can I have MATLAB label the points based on which coordinates (which are stored in a separate column) correspond with which name (if the names are stored in yet another column)?%% Plot maplatlim = [39 47];lonlim = [-81 -70];ax = worldmap('USA');load coastgeoshow(ax, lat, long,...'DisplayType', 'polygon', 'FaceColor', [.45 .60 .30])states = shaperead('usastatelo', 'UseGeoCoords', true, 'BoundingBox', [lonlim' latlim']);axesm('lambert', 'MapLatLimit', latlim, 'MapLonLimit', lonlim);faceColors = makesymbolspec('Polygon',... {'INDEX', [1 numel(states)], 'FaceColor', ... polcmap(numel(states))}); % NOTE - colors are randomgeoshow(ax, states, 'DisplayType', 'polygon', ... 'SymbolSpec', faceColors);figure('Color', 'white')title('PM2.5 Site in New York State in 2012');hold all% Plot pointsaxesm('lambert', 'MapLatLimit', latlim', 'MapLonLimit', lonlim');datalat = str2double(datalat);datalon = str2double(datalon);scatterm(datalat, datalon)推荐答案您可以使用usamap('New York')获取美国状态地图,并使用textm绘制覆盖文本.在这里,图中绘制了25个随机点及其标签.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.以下情节是由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) 这篇关于在MATLAB中在地图上绘制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-13 18:35