RunMat
GitHub

fill3 — Create 3-D filled polygon patches in MATLAB and RunMat.

fill3 creates filled polygon patch objects from X, Y, and Z coordinate data in 3-D axes. It reuses the shared patch pipeline, so handle behavior and patch name-value properties follow MATLAB semantics.

Syntax

h = fill3(X, Y, Z, C)
h = fill3(X1, Y1, Z1, C1, ..., Xn, Yn, Zn, Cn)
h = fill3(X1, Y1, Z1, C1, ..., Name, Value, ...)
h = fill3(ax, X, Y, Z, C)
h = fill3(ax, X1, Y1, Z1, C1, ..., Xn, Yn, Zn, Cn)
h = fill3(ax, X1, Y1, Z1, C1, ..., Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
XNumericArrayYesPolygon X coordinates.
YNumericArrayYesPolygon Y coordinates.
ZNumericArrayYesPolygon Z coordinates.
CAnyYesColor specification.
groupsAnyVariadicOne or more `(X, Y, Z, C)` polygon groups.
propsAnyVariadicTrailing patch name/value property pairs.
axAxesHandleYesTarget axes handle.

Returns

NameTypeDescription
hAnyHandle or row-vector of handles for created patch objects.

Errors

IdentifierWhenMessage
RunMat:fill3:InvalidArgumentInput groups, axes targeting, or trailing property pairs are invalid.fill3: invalid argument
RunMat:fill3:InternalInternal patch construction or rendering fails unexpectedly.fill3: internal operation failed

How fill3 works

  • fill3(X, Y, Z, C) creates one or more 3-D filled polygons from matching coordinate arrays.
  • Vector coordinate inputs create one polygon.
  • Matrix coordinate inputs create one polygon per column through the underlying patch parser.
  • Multiple X,Y,Z,C groups in one call create multiple patch objects and return a row vector of patch handles.
  • A single polygon group returns a scalar patch handle.
  • fill3 initializes the target axes with the standard 3-D view, so even polygons in the z=0 plane render as 3-D patch content.
  • Trailing patch property name-value pairs are applied to every polygon group in the call.
  • The returned patch handles work with get, set, ishandle, and isgraphics.
  • Color strings and RGB triples are supported through the shared patch color parser.
  • Indexed or interpolated CData behavior is currently limited by the underlying patch implementation; concrete color strings, RGB triples, and common patch properties are the supported color path.

Options

  • FaceColor accepts color names, RGB triples, flat, or none through patch.
  • EdgeColor accepts color names, RGB triples, or none.
  • FaceAlpha and EdgeAlpha accept numeric values from 0 to 1.
  • LineWidth, DisplayName, and Visible use the shared plotting property model.
  • Explicit axes handles are accepted as the leading argument, matching other RunMat plotting builtins.

Does RunMat run fill3 on the GPU?

fill3 shares patch rendering behavior, so host and gathered-GPU coordinate inputs produce the same patch objects and graphics handles.

Rendered geometry flows through the shared GPU plotting renderer after the patch objects are built.

A future direct GPU path should preserve the same X,Y,Z,C grouping and patch property semantics while replacing only the coordinate gathering and geometry packing stage.

GPU memory and residency

fill3 is a plotting sink and fusion barrier. GPU-resident coordinate inputs are gathered before patch construction because MATLAB-compatible parsing requires shape validation and polygon assembly.

Examples

Create a red square in the z=0 plane

x = [0 1 1 0];
y = [0 0 1 1];
z = [0 0 0 0];
h = fill3(x, y, z, 'r');
get(h, 'Type')

Expected output:

ans =
    'patch'

Create two filled polygons in one call

x1 = [0 1 0];
y1 = [0 0 1];
z1 = [0 0 0];
x2 = [2 3 3 2];
y2 = [0 0 1 1];
z2 = [1 1 1 1];
h = fill3(x1, y1, z1, 'g', x2, y2, z2, [0 0 1]);

Apply patch properties to a fill3 polygon

x = [0 1 0];
y = [0 0 1];
z = [0.25 0.5 0.75];
h = fill3(x, y, z, [0.25 0.5 0.75], 'EdgeColor', 'none', 'FaceAlpha', 0.5);

Create one patch per matrix column

X = [0 2; 1 3; 1 3; 0 2];
Y = [0 0; 0 0; 1 1; 1 1];
Z = [0 1; 0 1; 0 1; 0 1];
fill3(X, Y, Z, 'cyan');
view(3);

Using fill3 with coding agents

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

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

FAQ

What does fill3 return?

fill3 returns patch graphics handles. A single polygon group returns one scalar handle; multiple groups return a row vector of handles.

How is fill3 related to patch?

fill3 lowers its positional X,Y,Z,C inputs into the same patch object machinery. This keeps geometry validation, color parsing, property handling, rendering, and handle behavior consistent with patch.

Can I pass patch properties to fill3?

Yes. Trailing name-value pairs such as 'EdgeColor', 'none', 'FaceAlpha', 0.5, and 'LineWidth', 2 are forwarded to the patch objects created by fill3.

Does fill3 support GPU-resident inputs?

GPU-resident coordinate inputs are gathered through the shared patch path for validation and polygon construction, then the resulting geometry is rendered through RunMat's GPU plotting renderer.

Does fill3 support indexed CData?

The current implementation is constrained by patch: color strings and RGB triples are supported, while full MATLAB indexed/interpolated CData behavior is deferred.

2D Charts

area · 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 · hold · patch · print · suptitle · xline · yline

More plotting resources

Open-source implementation

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