RunMat
GitHub

yline — Draw horizontal reference lines on current or specified axes with MATLAB-compatible styling forms.

yline adds one or more horizontal reference lines with optional labels, line specs, and name-value styling, following MATLAB-compatible plotting behavior.

Syntax

h = yline(y)
h = yline(y, styleOrLabel)
h = yline(y, LineSpec, label)
h = yline(y, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
yNumericArrayYesY-coordinate scalar or numeric vector of horizontal line positions.
style_or_labelAnyNoLineSpec token (for example '--r') or label text.
linespecStyleSpecYesLine style token (for example '--r').
labelStringScalarYesReference line label text.
propsAnyVariadicStyle arguments and Name/Value pairs (Color, LineWidth, LineStyle, LabelOrientation, Visible).

Returns

NameTypeDescription
hNumericArrayReference line handle scalar or row vector when multiple coordinates are provided.

Errors

IdentifierWhenMessage
RunMat:yline:InvalidArgumentCoordinate input, style arguments, or Name/Value pairs are invalid.yline: invalid argument
RunMat:yline:InternalInternal plotting state update fails.yline: internal operation failed

How yline works

  • yline(y) adds a horizontal reference line at each coordinate in y.
  • Reference lines append to the current axes without replacing existing plot content.
  • Line spans follow the active axes limits, including later xlim and ylim changes.
  • The returned handle supports get and set for Value, Color, LineWidth, LineStyle, Label, LabelOrientation, DisplayName, and Visible.

Examples

Add a zero baseline

plot(-5:5, (-5:5).^2 - 10);
yline(0, 'k', 'LineWidth', 1);

Expected output:

% Adds a black horizontal reference line at y = 0

Label a baseline

plot(1:10, rand(1, 10));
yline(0.5, ':', 'Baseline', 'LabelOrientation', 'horizontal');

Expected output:

% Adds a dotted labeled horizontal reference line

Using yline with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how yline changes the result.

Run a small yline example, explain the result, then change one input and compare the output.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · print · suptitle · xline

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.