Plotting patchm or fillm on Geoplot or geoscatter
Show older comments
How can I plot a filled polygon using fillm or patchm on geoscatter?
I get:
Error using gcm (line 25)
Not a map axes.
Error in patchm (line 44)
mstruct = gcm;
Thanks!
Answers (1)
Naga
on 26 Nov 2024
Hello Navad,
To plot a filled polygon on a map using `fillm` or `patchm`, you need to ensure that you are working with a map axes. The error you are encountering indicates that the current axes is not recognized as a map axes. Here is an example to plot a filled polygon using 'fillm' on a map axes:
% Create a figure
figure;
% Initialize map axes with a Mercator projection
ax = axesm('MapProjection', 'mercator', 'Frame', 'on', 'Grid', 'on');
% Set the map limits for latitude and longitude
setm(ax, 'MapLatLimit', [33 36], 'MapLonLimit', [-119 -116]);
% Define latitude and longitude for the polygon vertices
lat = [34, 34, 35, 35];
lon = [-118, -117, -117, -118];
% Plot the filled polygon on the map axes
fillm(lat, lon, 'r'); % 'r' specifies the color red
% Add title and labels
title('Filled Polygon using fillm on Map Axes');
xlabel('Longitude');
ylabel('Latitude');
Categories
Find more on Vector and Raster Map Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!