RunMat
GitHub

area — Create filled area plots in MATLAB and RunMat.

area creates filled area plots from vector or matrix-style inputs. It returns an area handle, supports baseline/stacked behaviors, and participates in the shared MATLAB/RunMat plotting handle-property system.

Syntax

h = area(Y)
h = area(Y, LineSpec)
h = area(Y, Name, Value, ...)
h = area(X, Y)
h = area(X, Y, LineSpec)
h = area(X, Y, Name, Value, ...)
All supported area forms
h = area(Y)
h = area(Y, LineSpec)
h = area(Y, Name, Value, ...)
h = area(X, Y)
h = area(X, Y, LineSpec)
h = area(X, Y, Name, Value, ...)
h = area(ax, Y)
h = area(ax, Y, Name, Value, ...)
h = area(ax, X, Y)
h = area(ax, X, Y, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYesY data vector or matrix. Columns are rendered as stacked series.
lineSpecStyleSpecYesLine/color shorthand such as '--r'.
propsAnyVariadicName/value style properties such as Color, LineWidth, and BaseValue.
XNumericArrayYesX coordinates matching the row count of Y.
axAxesHandleYesTarget axes handle.

Returns

NameTypeDescription
hNumericScalarHandle to the first area series in the rendered chart.

Errors

IdentifierWhenMessage
RunMat:area:InvalidArgumentInput data, style tokens, or name/value options are invalid.area: invalid argument
RunMat:area:InternalRenderer/GPU conversion fails during chart construction.area: internal operation failed

How area works

  • area(y) uses implicit x-values 1:n, while area(x, y) uses explicit x coordinates.
  • Matrix-style y inputs create stacked area series in the MATLAB style.
  • The returned value is an area-handle object that works with get and set.
  • Baseline and color workflows flow through the shared plotting property model.
  • Stacked-series geometry can be emitted directly from GPU buffers on the happy path.

Options

  • 'BaseValue' sets the baseline used by area filling.
  • Color and display-name workflows are available through the returned handle and the shared plotting property path.

Does RunMat run area on the GPU?

The direct area path emits filled geometry from GPU data on the happy path.

Baseline semantics, stacked-series behavior, and handle/property workflows remain aligned across GPU and fallback paths.

GPU memory and residency

area preserves GPU residency on the direct path, including stacked-series geometry generation. Fallback rendering still preserves the same visible semantics and handle behavior when a direct GPU path is not available.

Examples

Create a basic filled area plot

x = 0:0.1:1;
area(x, x.^2);

Create stacked area series from a matrix

x = 1:5;
Y = [1 2 1; 2 1 2; 3 2 1; 2 3 2; 1 2 3];
area(x, Y);

Change the baseline and label the series through the handle

x = 0:0.2:2;
h = area(x, sin(x) + 2);
set(h, 'BaseValue', 1, 'DisplayName', 'offset area');
legend;

Stacked energy mix

years = 2018:2025;
solar   = [5  8  12 18 25 33 42 50];
wind    = [10 14 18 22 28 32 36 40];
hydro   = [30 30 29 28 27 27 26 26];
mix = [solar; wind; hydro]';

area(years, mix);
title('Energy Generation Mix');
xlabel('Year');
ylabel('TWh');
legend('Solar', 'Wind', 'Hydro');
grid on;
Expected output:
Stacked energy mix

Using area with coding agents

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

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

FAQ

How do I create a stacked area chart?

Pass a matrix as the y-data. Each column becomes a stacked series, and RunMat accumulates them vertically so the total is visible at the top.

x = 1:6;
Y = [2 3 1; 1 2 2; 3 1 2; 2 2 3; 1 3 1; 2 1 3];
area(x, Y);
legend('A', 'B', 'C');
How do I control the transparency of an area plot?

Set 'FaceAlpha' on the area handle to a value between 0 (fully transparent) and 1 (fully opaque). This is useful when overlaying multiple area series without stacking.

area(x, y1);
hold on;
h = area(x, y2);
set(h, 'FaceAlpha', 0.4);
What's the difference between area and plot?

area fills the region between the data line and the baseline, giving a visual sense of cumulative magnitude. plot just draws the line. Use area when the filled region conveys meaning—cumulative totals, part-to-whole breakdowns, or emphasizing the magnitude of a signal relative to a baseline.

2D Charts

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

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how area 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.