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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Y | NumericArray | Yes | — | Ribbon heights. Each matrix column becomes one ribbon. |
width | NumericScalar | Yes | 0.75 | Ribbon width around each column center. |
X | NumericArray | Yes | — | X coordinates for the rows of Y. |
args | Any | Variadic | — | Optional axes target and surface style name/value pairs. |
Returns
| Name | Type | Description |
|---|---|---|
h | Any | Surface handle or row vector of surface handles for the rendered ribbons. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:ribbon:InvalidArgument | Ribbon data, x coordinates, width, axes target, or style arguments are invalid. | ribbon: invalid argument |
RunMat:ribbon:Internal | Internal ribbon surface construction or rendering fails. | ribbon: internal operation failed |
How ribbon works
ribbon(Y)uses implicit x coordinates1:size(Y,1)and creates one surface ribbon per column ofY.ribbon(Y,width)uses the supplied positive finite ribbon width around each column center.ribbon(X,Y)andribbon(X,Y,width)useXas the x coordinates for each row ofY;numel(X)must match the number of rows inY.- Vector
Yinput, including row-vector input, creates a single ribbon surface. NaNheight values are preserved in the surfaceZData, 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, andVisibleare accepted through the same surface style parser used bysurf. - Each returned object has type
surface;getexposes the actual coordinate-gridXData,YData, andZDatafor each ribbon strip. - Surface handles support setting
XData,YData,ZData,FaceAlpha,FaceColor,EdgeColor,Shading,Colormap,DisplayName,Lighting,FlattenZ, andVisible; unsupported surface property names raise an error instead of silently no-oping. DisplayNamedefaults to the empty string unless supplied by a name/value pair or latersetcall.
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 handlesUse 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 30Style 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.7000Using 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.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · cla · clf · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · saveas · savefig · sphere · stackedplot · subtitle · suptitle · textscatter · textscatter3 · triplot · waitbar · wordcloud · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zoom
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how ribbon is executed, line by line, in Rust.
- View the source for ribbon in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.