xline
Vertical constant line.
📝Syntax
xline(xvalue)
xline(xvalue, LineSpec)
xline(xvalue, LineSpec, label)
xline(xvalue, propertyName, propertyValue)
xline(ax, xvalue)
cl = xline(xvalue)
📥Input Arguments
Parameter Description
xvalue a real numeric scalar or vector: location of the vertical line(s) on the x-axis.
LineSpec a row vector character or a scalar string: line style and color, for example '--r'.
label a row vector character, a scalar string or a cell of character vectors: text displayed next to the line.
ax Target axes: axes object.
propertyName a scalar string or row vector character.
propertyValue a value.
📤Output Arguments
Parameter Description
cl a graphics object: ConstantLine type.
📄Description

xline(xvalue) draws a vertical line at the value xvalue on the current axes. The line spans the full height of the axes.

Use a LineSpec to set the line style and color, and a label to annotate the line.

When xvalue is a vector, one vertical line is created for each value.

💡Examples
f = figure();
plot(1:10, (1:10).^2);
xline(5, '--r', 'threshold');
f = figure();
plot(-10:10, (-10:10).^2);
xline([-3 3], 'Color', [0 0 1], 'LineWidth', 2);
🔗See Also
ylinelineplot
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub