Main Content

Use Geographic and Nongeographic Objects in Map Axes

This example shows how to use geographic and nongeographic objects in a map axes. The example illustrates the difference between using MATLAB functions, such as plot and grid, and their Mapping Toolbox counterparts, plotm and gridm .

Make a Miller map axes with a latitude and longitude grid. These functions create a map axes object, a map frame enclosing the region of interest, and geographic grid lines. The x-y axes, which are normally hidden, are displayed, and the axes x-y grid is turned off. The gridm function constructs lines to illustrate the latitude-longitude grid, unlike the MATLAB grid function, which draws an x-y grid for the underlying projected map coordinates. Depending on the type of projection, a latitude-longitude grid (or graticule) can contain curves while a MATLAB grid never does.

axesm miller; 
framem on;
gridm on;
mlabel on;
plabel on;
grid off;

Place a standard MATLAB text object and a mapped text object, using the two separate coordinate systems. In the figure, a standard text object is placed at x=-2 and y=-1, while the mapped text object is placed at (70 degrees N, 150 degrees W) in the Miller projection.

text(-2,-1,'Standard text object at x = -2, y = -1')
textm(70,-150,'Mapped text object at lat = 70, lon = -150')

Change the projection to sinusoidal. The standard text object remains at the same Cartesian position, which alters its latitude-longitude position. The mapped text object remains at the same geographic location, so its x-y position is altered. Also, the frame and grid lines reflect the new map projection. Similarly, vector and raster (matrix) data can be displayed using either mapping functions ( plotm ) or standard functions ( plot ).

grid off; 
mlabel off