ribbon — Create 3-D ribbon plots from columns of data.

ribbon(Y) renders each column of Y as a 3-D surface strip. Optional X coordinates control the row positions, and optional width controls the strip width around each column center. The return value is a surface handle for vector input or a row vector of surface handles for matrix input.

Syntax

h = ribbon(Y)
h = ribbon(Y, width)
h = ribbon(X, Y)
h = ribbon(X, Y, width)
h = ribbon(___, Name, Value, ...)
h = ribbon(ax, ___)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYesRibbon heights. Each matrix column becomes one ribbon.
widthNumericScalarYes0.75Ribbon width around each column center.
XNumericArrayYesX coordinates for the rows of Y.
argsAnyVariadicOptional axes target and surface style name/value pairs.

Returns

NameTypeDescription
hAnySurface handle or row vector of surface handles for the rendered ribbons.

Errors

IdentifierWhenMessage
RunMat:ribbon:InvalidArgumentRibbon data, x coordinates, width, axes target, or style arguments are invalid.ribbon: invalid argument
RunMat:ribbon:InternalInternal ribbon surface construction or rendering fails.ribbon: internal operation failed

How ribbon works

  • ribbon(Y) uses implicit x coordinates 1:size(Y,1) and creates one surface ribbon per column of Y.
  • ribbon(Y,width) uses the supplied positive finite ribbon width around each column center.
  • ribbon(X,Y) and ribbon(X,Y,width) use X as the x coordinates for each row of Y; numel(X) must match the number of rows in Y.
  • Vector Y input, including row-vector input, creates a single ribbon surface.
  • NaN height values are preserved in the surface ZData, allowing callers to represent missing or interrupted ribbon geometry.
  • The axes-target form ribbon(ax,...) renders into the supplied axes handle.
  • Surface style name/value pairs such as FaceAlpha, FaceColor, EdgeColor, Shading, Colormap, DisplayName, Lighting, and Visible are accepted through the same surface style parser used by surf.
  • Each returned object has type surface; get exposes the actual coordinate-grid XData, YData, and ZData for each ribbon strip.
  • Surface handles support setting XData, YData, ZData, FaceAlpha, FaceColor, EdgeColor, Shading, Colormap, DisplayName, Lighting, FlattenZ, and Visible; unsupported surface property names raise an error instead of silently no-oping.
  • DisplayName defaults to the empty string unless supplied by a name/value pair or later set call.

Examples

Create a ribbon plot from matrix columns

Y = [1 4; 2 5; 3 6];
h = ribbon(Y);

Expected output:

% h is a vector of surface handles

Use explicit x coordinates and width

x = [10 20 30];
Y = [2; 3; 4];
h = ribbon(x, Y, 0.5);
get(h, 'XData')

Expected output:

ans =
    10    10
    20    20
    30    30

Style ribbon surfaces

Y = [1 3 2; 2 4 3; 3 5 4];
h = ribbon(Y, 0.4, 'FaceAlpha', 0.7, 'DisplayName', 'bands');
get(h(1), 'FaceAlpha')

Expected output:

ans =
    0.7000

Using ribbon with coding agents

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

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

FAQ

Does ribbon create a new plot primitive?

No. RunMat lowers each ribbon to a standard surface strip, so existing surface rendering, scene serialization, and get/set behavior apply.

What does the width argument mean?

The width is the total span of each strip around its column center. With the default width 0.75, the first ribbon spans y positions 0.625 through 1.375.

Can ribbon preserve gpuArray residency?

Not yet. surf can preserve provider residency for separable X/Y axes plus a Z buffer, but ribbon needs generated full coordinate grids for each strip. That provider-resident grid construction belongs to the queued GPU fast-path audit work.

Open-source implementation

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