xline — Draw vertical reference lines on the current axes.
xline adds one or more vertical reference lines to the current axes. It accepts scalar or vector x-coordinates, MATLAB line specs, labels, and common line name/value styling such as Color, LineStyle, LineWidth, and DisplayName.
How xline works
xline(x)adds a vertical reference line at each coordinate inx.- Reference lines append to the current axes without replacing existing plot content.
- Line spans follow the active axes limits, including later
xlimandylimchanges. - The returned handle supports
getandsetforValue,Color,LineWidth,LineStyle,Label,LabelOrientation,DisplayName, andVisible.
Examples
Add a dashed threshold line
plot(1:10, rand(1, 10));
xline(5, '--r', 'Threshold');Expected output:
% Adds a red dashed vertical reference line at x = 5Add multiple reference lines
plot(1:10, rand(1, 10));
xline([2 5 8], ':');Expected output:
% Adds three dotted vertical reference linesRelated Plotting functions
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.