Scale bar for 2D axes
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 (2024). 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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.