image thumbnail

Scale bar for 2D axes

version 1.1.0.0 (9.86 KB) by Amanda
Creates a scale bar in a 2D axes. The length, location and colour of the scale bar are customisable.

2.4K Downloads

Updated 24 Mar 2014

View License

SCALEBAR creates a scalebar on an axes

SCALEBAR
SCALEBAR OFF
SCALEBAR(PARAMETER, VALUE, ...)
SCALEBAR(HAXES, PARAMETER, VALUE, ...)
H = SCALEBAR(...)

Draws a scalebar on the axes and returns handle to the scalebar. The DataAspectRatio property of the axes must be set to [1 1 1] and the view must be in 2D. All parameters are optional (note the default values below). SCALEBAR OFF deletes the current scalebar.

PARAMETER/VALUE pairs
hAxes: handle to the axes (defaults to current axes)
ScaleLength: length to show (in data units) (defaults to ~10% of the x-axis limit range)
ScaleLengthRatio: ScaleLength/range(XLim)
Location: location of the scalebar. Possible values are
northeast (default)
northwest
southeast
southwest
[x y] data coordinates
Colour: colour of scalebar in 1x3 RGB array (default is [0 0 0])
Bold: draw with bold text and linewidth=2. True or false(default)
Unit: string containing units e.g. 'mm'

Cite As

Amanda (2022). Scale bar for 2D axes (https://www.mathworks.com/matlabcentral/fileexchange/25799-scale-bar-for-2d-axes), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!