Strange values of map axes limits (axesm).

4 views (last 30 days)
Peter Valent
Peter Valent on 15 Dec 2021
Answered: Jan Studnicka on 16 Dec 2021
I am building an app that will display various geographic data - vector (points, lines, polygons) and raster. Because of this I would like to plot the data on map axes which can be created using the axesm function. Let's say that all the data I would like to plot will have geographic coordinates (lat,lon). I have problems with understanding the limits (both horizontal and vertical) of the axes. What do the numbers mean?
Les't have a look at this simple example which plots a polyline in geographic coordinates on map axes.
s = geoshape([42 45],[10 15]);
a = axesm('mercator');
geoshow(a,s)
It produces a very simple plot, where the limits of the horizontal axis should be for sure somewhere between 40 and 50. However, when I try to get the limits of the horizontal axis I get strange values that are nowhere what I would expect (see the code below).
a.XLim % this gives me [0.16,0.28]
getm(a,'FLatLimits') % this gives me [-86,86]
I need to know the limits of both the horizontal and the vertical axes in correct geographic coordinates due to resizing function in the app.
SIMPLE EXAMPLE:

Answers (1)

Jan Studnicka
Jan Studnicka on 16 Dec 2021
Hello,
The default setting for map axes is that the map frame is not visible. You need to toggle the visibility of the map frame by calling:
framem on
s = geoshape([42 45],[10 15]);
figure
a = axesm('mercator');
geoshow(a,s)
framem on
figure
s = geoshape([42 45],[10 15]);
a2 = axesm('mercator','MapLatLimit',[30 60],'MapLonLimit',[0 30]);
geoshow(a2,s)
framem on
mlabel on
plabel on
tightmap
gridm

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!