scaleline

scaleline(varargin)

SCALELINE Adds a scale line to the x or y axis of a figure. Line scales with zoom.

Usage:

[h_scaleline, h_scalelabel]=scaleline(ax,time) [h_scaleline, h_scalelabel]=scaleline(ax,time,label) [h_scaleline, h_scalelabel]=scaleline(ax,time,label,line_axis) [h_scaleline, h_scalelabel]=scaleline(ax,time,label,line_axis,gap)

Input: ax: Axis to which to add the line (default: gca) time: Scale line length (in plot units) label: Label text for scale line (default: blank) line_axis: Axis to which the line is attached, ‘x’ or ‘y’ (default: ‘x’) gap: Gap between line and axis in normalized units (default: .01)

Output: h_scaleline: Handle to the scale line h_scalelabel: Handle to the scale label

Example:

figure plot(randn(1,10000)*10000) axis tight; xlabel(‘Time (seconds)’); ylabel(‘Voltage (V)’);

%Add x and y scale lines scaleline(gca,1000,’1000 seconds’); scaleline(gca,5000,’5000 V’,’y’);

zoom; msgbox(‘Zoom to change scale line limits’);

Copyright 2011 Michael J. Prerau, Ph.D.

Last modified 01/06/2015