RunMat
GitHub

errorbar — Create plots with symmetric or asymmetric error bars using MATLAB-compatible errorbar forms.

errorbar visualizes uncertainty using vertical error bars with symmetric or asymmetric magnitudes. It returns graphics handles and follows MATLAB-compatible argument and property forms.

Syntax

h = errorbar(Y, E)
h = errorbar(X, Y, E)
h = errorbar(X, Y, YNeg, YPos)
h = errorbar(X, Y, XNeg, XPos, YNeg, YPos)
h = errorbar(ax, ...)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYesData values.
ENumericArrayYesSymmetric Y error magnitudes.
XNumericArrayYesX coordinates.
YNumericArrayYesY coordinates.
YNegNumericArrayYesNegative Y error magnitudes.
YPosNumericArrayYesPositive Y error magnitudes.
XNegNumericArrayYesNegative X error magnitudes.
XPosNumericArrayYesPositive X error magnitudes.
axNumericScalarYesTarget axes handle.
dataAnyVariadicErrorbar positional data arguments.
propsAnyVariadicStyle and name/value properties.

Returns

NameTypeDescription
hNumericScalarHandle to the created error bar series.

Errors

IdentifierWhenMessage
RunMat:errorbar:InvalidArgumentInput vectors, error vectors, style arguments, or axes-target forms are malformed.errorbar: invalid argument
RunMat:errorbar:InternalInternal render preparation or GPU vertex generation fails.errorbar: internal operation failed

How errorbar works

  • Vertical-only and both-direction error-bar forms are supported through the runtime and replay/render stack.
  • The returned value is an error-bar handle that can be queried or updated through get and set.
  • Cap size, line styling, marker appearance, display names, and related properties use the shared plotting object/property system.
  • Error bars remain subplot-local and integrate naturally with legends and axes state.
  • GPU-backed geometry is used when plotting-compatible buffers are available for the full input set; otherwise RunMat falls back to host plotting while preserving the same visible result.

Does RunMat run errorbar on the GPU?

Dedicated GPU geometry generation covers supported vertical and both-direction error-bar workflows.

Markers continue to use the shared marker path so line/marker styling stays consistent with the rest of the plotting stack.

GPU memory and residency

errorbar preserves GPU residency when the direct error-bar packer path is available for the full input set. Marker rendering stays aligned with the shared marker path.

Examples

Plot symmetric vertical error bars

x = 1:5;
y = [2 3 2.5 4 3.5];
err = [0.2 0.3 0.1 0.4 0.2];
errorbar(x, y, err, err);

Plot asymmetric both-direction error bars

x = 1:4;
y = [3 4 2 5];
xn = [0.1 0.2 0.1 0.3];
xp = [0.2 0.3 0.2 0.4];
yn = [0.3 0.2 0.4 0.2];
yp = [0.4 0.3 0.5 0.3];
errorbar(x, y, xn, xp, yn, yp);

Style an error-bar object and label it for the legend

x = 1:5;
y = [1 2 1.5 3 2.5];
h = errorbar(x, y, 0.2*ones(size(x)), 0.2*ones(size(x)));
set(h, 'LineWidth', 2, 'DisplayName', 'measurement');
legend;

Measurements with confidence intervals

x = 1:8;
y = [2.1 3.4 4.2 5.8 5.5 6.1 7.3 8.0];
neg = [0.3 0.4 0.2 0.5 0.6 0.3 0.4 0.3];
pos = [0.4 0.3 0.3 0.6 0.5 0.4 0.5 0.4];

errorbar(x, y, neg, pos, 'o-', 'LineWidth', 1.5);
title('Tensile Strength vs. Sample');
xlabel('Sample #');
ylabel('Strength (MPa)');
grid on;
Expected output:
Measurements with confidence intervals

Using errorbar with coding agents

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

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

FAQ

How do I plot asymmetric error bars?

Pass separate lower and upper error vectors. For vertical-only asymmetric bars, use errorbar(x, y, neg, pos) where neg is the downward extent and pos is the upward extent.

x = 1:5;
y = [2 3 2.5 4 3.5];
neg = [0.1 0.2 0.15 0.3 0.1];
pos = [0.3 0.4 0.2 0.5 0.25];
errorbar(x, y, neg, pos);
Can I add horizontal error bars?

Yes. Use the six-argument form errorbar(x, y, yneg, ypos, xneg, xpos) to get both vertical and horizontal bars. If you only want horizontal bars, set the vertical error vectors to zero.

x = 1:4; y = [3 4 2 5];
errorbar(x, y, zeros(size(x)), zeros(size(x)), 0.2*ones(size(x)), 0.3*ones(size(x)));
Can I combine error bars with a line or scatter plot?

Yes—errorbar already draws a line through the data points by default. To overlay error bars on a separate plot, call hold on first. The error bar handle supports the same set properties as line handles, so you can match colors and widths.

plot(x, y, 'b-', 'LineWidth', 2);
hold on;
errorbar(x, y, err, err, 'LineStyle', 'none', 'Color', 'b');

2D Charts

area · bar · 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 · polarplot · print · suptitle · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how errorbar is executed, line by line, in Rust.

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.