Documentation Center

  • Trial Software
  • Product Updates

Controlling Map Frames and Grids

The Map Frame

The Mapping Toolbox™ map frame is the outline of the limits of a map, often in the form of a box, the "edge of the world," so to speak. The frame is displayed if the map axes property Frame is set to 'on'. This can be accomplished upon map axes creation with axesm, or later with setm, or with the direct command framem on. The frame is geographically defined as a latitude-longitude quadrangle that is projected appropriately. For example, on a map of the world, the frame might extend from pole to pole and a full 360º range of longitude. In appearance, the frame would take on the characteristic shape of the projection. The examples below are full-world frames shown in four very different projections.

Full-World Map Frames

As a map object, each of the previously displayed frames is identical; however, the selection of a display projection has varied their appearance. Because each of the examples shows the entire world, FLatLimit is [-90 90], and FLonLimit is [-180 180] for each case. The frame quadrangle can encompass smaller regions, as well, in which case the shape is a section of a full-world outline or simply a quadrilateral with straight or curving sides. Execute this code to produce the figure that follows:

% Plot four regions of Robinson frame and grid using map limits
%
figure('color','white')
% Default map frame
subplot(2,2,1);
axesm('MapProjection','robinson',...
    'Frame','on','Grid','on')
title('Latitude [-90 90], Map lons [-180 180]','FontSize',10)
%
subplot(2,2,2);
axesm('MapProjection','robinson',...
    'MapLatLimit',[30 70],'MapLonLimit',[-90 90],...
    'Frame','on','Grid','on')
title('Latitude [30 70], Longitude [-90 90]','FontSize',10)
%
subplot(2,2,3);
axesm('MapProjection','robinson',...
    'MapLatLimit',[-90 0],'MapLonLimit',[-180 -30],....
    'Frame','on','Grid','on')
title('Latitude [-90 0], Longitude [-180 -30]','FontSize',10)
%
subplot(2,2,4);
axesm('MapProjection','robinson',...
    'MapLatLimit',[-70 -30],'MapLonLimit',[60 150],...
    'Frame','on','Grid','on')
title('Latitude [-70 -30], Longitude [60 150]','FontSize',10)

Frame Quadrangles in the Robinson Projection (Symmetric About Prime Meridian)

For the frames shown above, the projection is centered on the prime meridian, or 0 longitude. Such a frame would be the result of creating a map axes with the defaults for the Robinson projection and then resetting the frame limits to cover just part of the world.

When you want your frame to be symmetric about the region of interest, let axesm determine the proper settings for you. If you specify the map limits without specifying the map origin and frame limits, axesm will automatically set the appropriate values for a proper symmetric frame.

In the following example, the axes limits are set using setm after the Robinson map axes is created. Note that map axes properties that concern frames begin with "F":

% Same regions as above, but with frame limits
%    altered after projecting
%
figure('color','white')
% Default frame limits
h11 = subplot(2,2,1);
axesm('MapProjection','robinson',...
    'Frame','on','Grid','on')
title('Latitude [-90 90], Longitude [-180 180]')
%
h12 = subplot(2,2,2);
axesm('MapProjection','robinson',...
    'Frame','on','Grid','on')
setm(h12,'FLatLimit',[30 70],'FLonLimit',[-90 90])
title('Latitude [30 70], Longitude [-90 90]')
%
h21 = subplot(2,2,3);
axesm('MapProjection','robinson',...
    'Frame','on','Grid','on')
setm(h21,'FLatLimit',[-90 0],'FLonLimit',[-180 -30])
title('Latitude [-90 0], Longitude [-180 -30]')
%
h22 = subplot(2,2,4);
axesm('MapProjection','robinson',...
    'Frame','on','Grid','on')
setm(h22,'FLatLimit',[-70 -30],'FLonLimit',[60 150])
title('Latitude [-70 -30], Longitude [60 150]')

Frame Quadrangles in the Robinson Projection (Symmetric About Map Limits)

The differences between the two examples are obvious when projections are not centered on the prime meridian. If you wanted to create a symmetric frame in the lower right subplot of the above figure, reset the map limits instead of the frame limits, but be sure to reset the 'Origin' property in the same call:

setm(h22,'MapLonLimit',[60 150],'Origin',[])

You can manipulate properties beyond the latitude and longitude limits of the frame. Frame properties are established upon map axes object creation; you can modify them subsequently with the setm and the framem functions. The command framem alone is a toggle for the Frame property, which controls the visibility of the frame. You can also call framem with property names and values to alter the appearance of the frame:

framem('FlineWidth',4,'FEdgeColor','red')

The frame is actually a patch with a default face color set to 'none' and a default edge color of black. You can alter these map axes properties by manipulating the FFaceColor and FEdgeColor properties. For example, the command

setm(gca,'FFaceColor','cyan')

makes the background region of your display resemble water. Since the frame patch is always the lowest layer of a map display, other patches, perhaps representing land, will appear above the "water." If an object is subsequently plotted "below" the frame patch, the frame altitude can be recalculated to lie below this object with the command framem reset. The frame is replaced and not reprojected.

Set the line width of the edge, which is 2 points by default, using the FLineWidth property.

The primary advantage of displaying the map frame is that it can provide positional context for other displayed map objects. For example, when vector data of the coasts is displayed, the frame provides the "edge" of the world.

See the framem reference page for more details.

Map and Frame Limits

The Mapping Toolbox map and frame limits are two related map axes properties that limit the map display to a defined region. The map latitude and longitude limits define the extents of geodata to be displayed, while the frame limits control how the frame fits around the displayed data. Any object that extends outside the frame limits is automatically trimmed.

The frame limits are also specified differently from the map limits. The map limits are in absolute geographic coordinates referenced to an origin at the intersection of the prime meridian and the equator, while the frame limits are referenced to the rotated coordinate system defined by the map axes origin.

For all nonazimuthal projections, frame limits are specified as quadrangles ([latmin latmax] and [longmin longmax]) in the frame coordinate system. In the case of azimuthal projections, the frames are circular and are described by a polar coordinate system. One of the frame latitude limits must be a negative infinity (-Inf) to indicate an azimuthal frame (think of this as the center of the circle), while the other limit determines the radius of the circular frame (rlatmax). The longitude limits of azimuthal frames are inconsequential, since a full circle is always displayed.

If you are uncertain about the correct format for a particular projection frame limit, you can reset the formats to the default values using empty matrices.

    Note   For nonazimuthal projections in the normal aspect, the map extent is limited by the minimum of the map limits and the frame limits; hence, the two limits will coincide after evaluation. Therefore, if you manually change one set of limits, you might want to clear the other set to get consistent limits.

The Map Grid

The map grid is the set of displayed meridians and parallels, also known as a graticule. Display the grid by setting the map axes property Grid to 'on'. You can do this when you create map axes with axesm, with setm, or with the direct command gridm on.

Grid Spacing

To control display of meridians and parallels, set a scalar meridian spacing or a vector of desired meridians in the MLineLocation property. The property PLineLocation serves a corresponding purpose for parallels. The default values place grid lines every 30º for meridians and every 15º for parallels.

Grid Layering

By default, the grid is placed as the top layer of any display. You can alter this by changing the GAltitude property, so that other map objects can be placed "above" the grid. The new grid is drawn at its new altitude. The units used for GAltitude are specified with the daspectm function.

To reposition the grid back to the top of the display, use the command gridm reset. You can also control the appearance of grid lines with the GLineStyle and GLineWidth properties, which are ':' and 0.5, respectively, by default.

Limiting Grid Lines

The Miller projection is an example in which all the meridians can extend to the poles without appearing to be cluttered. In other projections, such as the orthographic (below), the map grid can obscure the surface where they converge. Two map axes properties, MLineLimit and MLineException, enable you to control such clutter:

  • Use the MLineLimit property to specify a pair of latitudes at which to terminate the meridians. For example, setting MLineLimit to [-75 75] completely clears the region above and below this latitude range of meridian lines.

  • If you want some lines to reach the poles but not others, you can specify them with the MLineException property. For example, if MLineException is set to [-90 0 90 180], then the meridians corresponding to the four cardinal longitudes will continue past the limit on to the pole.

The use of these properties is illustrated in the figure below. Note that there are two corresponding map axes properties, PLineLimit and PLineException, for controlling the extent of displayed parallels.

Labeling Grids

You can label displayed parallels and meridians. MeridianLabel and ParallelLabel are on-off properties for displaying labels on the meridians and parallels, respectively. They are both 'off' by default. Initially, the label locations coincide with the default displayed grid lines, but you can alter this by using the PlabelLocation and MlabelLocation properties. These grid lines are labeled across the north edge of the map for meridians and along the west edge of the map for parallels. However, the property MlabelParallel allows you to specify 'north', 'south', 'equator', or a specific latitude at which to display the meridian labels, and PlabelMeridian allows the choice of 'west', 'east', 'prime', or a specific longitude for the parallel labels. By default, parallel labels are displayed in the range of 0° to 90° north and south of the equator while meridian labels are displayed in the range of 0° to 180° east and west of the prime meridian. You can use the mlabelzero22pi function to redisplay the meridian labels in the range of 0° to 360° east of the prime meridian.

Properties affecting grid labeling are listed below.

Property

Effect

MeridianLabel

Toggle display of meridian labels

ParallelLabel

Toggle display of parallel labels

MlabelLocation

Alternate interval for labeling meridians

PlabelLocation

Alternate interval for labeling parallels

MlabelParallel

Keyword or latitude for placing meridian labels

PlabelMeridian

Keyword or longitude for placing parallel labels

mlabelzero22pi(function)

Relabel meridians with positive angle from 0° to 360°

For complete descriptions of all map axes properties, refer to the axesm reference page.

Was this topic helpful?