| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Mapping Toolbox |
| Contents | Index |
| Learn more about Mapping Toolbox |
Graphic scale elements are used to provide indications of size even more frequently than insets are. These are ruler-like objects that show distances on the ground at the nominal scale of the projection. You can use the scaleruler function to add a graphic scale to the current map. You can check and modify the scaleruler settings using getm and setm. You can also move the graphic scale to a new position by dragging its baseline.
Try this by creating a map, adding a graphic scale with the default settings, and shifting its location. Then add a second scale in nautical miles, and change the tick mark style and direction:
Use usamap to plot a map of Texas and surrounding states as filled polygons:
states = shaperead('usastatehi.shp', 'UseGeoCoords', true);
usamap('Texas')
faceColors = makesymbolspec('Polygon',...
{'INDEX', [1 numel(states)], ...
'FaceColor', polcmap(numel(states))});
geoshow(states,'DisplayType', 'polygon',...
'SymbolSpec', faceColors)Because polcmap randomizes patch colors, your display can look different.

Add a default graphic scale and then move it to a new location:
scaleruler on
setm(handlem('scaleruler1'),'YLoc',.5)The units of scaleruler default to kilometers. Note that handlem accepts the keyword 'scaleruler' or 'scaleruler1' for the first scaleruler, 'scaleruler2' for the second one, etc. If there is more than one scaleruler on the current axes, specifying the keyword 'scaleruler' returns a vector of handles.

Obtain a handle to the scaleruler's hggroup using handlem and inspect its properties using getm:
s = handlem('scaleruler');
getm(s)
ans =
Azimuth: 0
Children: 'scaleruler1'
Color: [0 0 0]
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 9
FontUnits: 'points'
FontWeight: 'normal'
Label: ''
Lat: 19.07296767149959
Long: 24.00830075180499
LineWidth: 0.50000000000000
MajorTick: [0 100 200 300 400 500]
MajorTickLabel: {6x1 cell}
MajorTickLength: 20
MinorTick: [0 25 50 75 100]
MinorTickLabel: '100'
MinorTickLength: 12.50000000000000
Radius: 'earth'
RulerStyle: 'ruler'
TickDir: 'up'
TickMode: 'auto'
Units: 'km'
XLoc: 0.15000000000000
YLoc: 0.50000000000000
ZLoc: []Change the scaleruler's font size to 8 points:
setm(s,'fontsize',8)
Place a second graphic scale, this one in units of nautical miles:
scaleruler('units','nm')setm(handlem('scaleruler2'), 'YLoc', .48,...
'MajorTick', 0:100:300,...
'MinorTick', 0:25:50, 'TickDir', 'down',...
'MajorTickLength', km2nm(25),...
'MinorTickLength', km2nm(12.5))

Experiment with the two other ruler styles available:
setm(handlem('scaleruler1'), 'RulerStyle', 'lines')
setm(handlem('scaleruler2'), 'RulerStyle', 'patches')

![]() | Inset Maps | North Arrows | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |