RunMat
GitHub

errorbar — Plot data with symmetric or asymmetric error bars for uncertainty, intervals, and MATLAB errorbar workflows.

errorbar visualizes uncertainty around data points using vertical or both-direction error bars. In RunMat it returns a plot handle, supports MATLAB-style symmetric and asymmetric forms, and participates in the same handle/property and marker-rendering system used by line-like plotting builtins.

How errorbar works in RunMat

  • 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.

How errorbar runs 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

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');

These functions work well alongside errorbar. Each page has runnable examples you can try in the browser.

stem, plot, legend, get, set

More plotting resources

Open-source implementation

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

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.

Getting started · Benchmarks · Pricing

Try RunMat for free

Open the sandbox and start running MATLAB code in seconds. No account required.