yline
Horizontal constant line.
📝Syntax
yline(yvalue)
yline(yvalue, LineSpec)
yline(yvalue, LineSpec, label)
yline(yvalue, propertyName, propertyValue)
yline(ax, yvalue)
cl = yline(yvalue)
📥Input Arguments
Parameter Description
yvalue a real numeric scalar or vector: location of the horizontal line(s) on the y-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

yline(yvalue) draws a horizontal line at the value yvalue on the current axes. The line spans the full width of the axes.

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

When yvalue is a vector, one horizontal line is created for each value.

💡Examples
f = figure();
plot(1:10, (1:10).^2);
yline(50, '-.b', 'mean');
f = figure();
plot(1:10, sin(1:10));
yline([-1 0 1], 'Color', [0 0 1]);
🔗See Also
xlinelineplot
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub