Main Content

northarrow

Add north arrow to axesm-based map

Syntax

northarrow
northarrow('property',value,...)

Description

northarrow creates a default north arrow.

northarrow('property',value,...) creates a north arrow using the specified property/value pairs. Valid entries for properties are 'latitude', 'longitude', 'facecolor', 'edgecolor', 'linewidth', and 'scaleratio'. The 'latitude' and 'longitude' properties specify the location of the north arrow. The 'facecolor', 'edgecolor', and 'linewidth' properties control the appearance of the north arrow. The 'scaleratio' property represents the size of the north arrow as a fraction of the size of the axes. A 'scaleratio' value of 0.10 creates a north arrow one-tenth (1/10) the size of the axes. You can change the appearance ('facecolor', 'edgecolor', and 'linewidth') of the north arrow using the set command.

The northarrow function creates a north arrow symbol at the map origin on the displayed map. You can reposition the north arrow symbol by clicking and dragging its icon. Alternatively, open a dialog box that you can use to change the location of the north arrow by right-clicking or Ctrl-clicking the arrow. The orientation of the north arrow is computed for you, and does not need manual adjustment, no matter where you move the symbol.

Modifying some of the properties of the north arrow results in replacement of the original object. Use HANDLEM('NorthArrow') to get the handles associated with the north arrow.

Examples

collapse all

Create a map of Texas. Add the north arrow in the lower left of the map.

figure
usamap("texas")
states = readgeotable("usastatelo.shp");
faceColors = makesymbolspec("Polygon",...
         {'INDEX',[1 numel(states)],'FaceColor',polcmap(height(states))});
geoshow(states,"DisplayType","polygon","SymbolSpec",faceColors)
northarrow("Latitude",25,"Longitude",-105,"LineWidth",1.5);

Figure contains an axes object. The hidden axes object contains 19 objects of type patch, line, text.

Change the edge and face colors of the north arrow.

h = handlem("NorthArrow");
set(h,"FaceColor",[1 0.8431 0],"EdgeColor",[0.01 0.01 0.9])

Figure contains an axes object. The hidden axes object contains 19 objects of type patch, line, text.

Create a map centered at the South Pole. Add a north arrow at a specified geographic position.

GT = readgeotable("landareas.shp");
antarctica = GT(GT.Name == "Antarctica",:);
figure
worldmap("south pole")
geoshow(antarctica)
northarrow("latitude",-57,"longitude",135);

Figure contains an axes object. The hidden axes object contains 22 objects of type patch, line, text.

Change the appearance of the north arrow.

h = handlem("NorthArrow");
set(h,"FaceColor", [1.000 0.8431 0.0000], ...
      "EdgeColor", [0.0100 0.0100 0.9000])

Figure contains an axes object. The hidden axes object contains 22 objects of type patch, line, text.

Show that every direction from the South Pole is north by creating three more north arrows. Note that north arrows are objects in the axes with Cartesian coordinates, not mapping objects. As a result, if you create more than one north arrow, any Mapping Toolbox™ function that manipulates a north arrow will affect only the last one drawn.

northarrow("latitude",-57,"longitude", 45);
northarrow("latitude",-57,"longitude",225);
northarrow("latitude",-57,"longitude",315);

Figure contains an axes object. The hidden axes object contains 28 objects of type patch, line, text.

Limitations

You can draw multiple north arrows on the map. However, the callbacks will only work with the most recently created north arrow. In addition, since it can be displayed outside the map frame limits, the north arrow is not converted into a “mapped” object. Hence, the location and orientation of the north arrow have to be updated manually if the map origin or projection changes.

Version History

Introduced before R2006a

See Also