RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • addpoints
    • ancestor
    • animatedline
    • area
    • autumn
    • axes
    • axis
    • bar
    • barh
    • bone
    • box
    • caxis
    • cla
    • clf
    • clim
    • colorbar
    • colorcube
    • colormap
    • colororder
    • contour
    • contour3
    • contourf
    • cool
    • copper
    • copyobj
    • cylinder
    • daspect
    • datacursormode
    • dataTipTextRow
    • drawnow
    • errorbar
    • fcontour
    • figure
    • fill
    • fill3
    • findobj
    • fsurf
    • gca
    • gcf
    • get
    • gobjects
    • gray
    • grid
    • groot
    • heatmap
    • hgload
    • hgsave
    • hidden
    • hist
    • histogram
    • histogram2
    • hold
    • hot
    • image
    • imagesc
    • imshow
    • inferno
    • isgraphics
    • ishandle
    • jet
    • legend
    • line
    • lines
    • linkaxes
    • loglog
    • magma
    • mesh
    • meshc
    • openfig
    • opengl
    • pan
    • parula
    • patch
    • pie
    • pink
    • plasma
    • plot
    • plot3
    • plotmatrix
    • plotyy
    • polarhistogram
    • polarplot
    • polarscatter
    • print
    • quiver
    • quiver3
    • ribbon
    • saveas
    • savefig
    • scatter
    • scatter3
    • semilogx
    • semilogy
    • set
    • sgtitle
    • shading
    • sphere
    • spring
    • stackedplot
    • stairs
    • stem
    • subplot
    • subtitle
    • summer
    • suptitle
    • surf
    • surfc
    • text
    • textscatter
    • textscatter3
    • title
    • triplot
    • turbo
    • view
    • viridis
    • waitbar
    • winter
    • wordcloud
    • xlabel
    • xlim
    • xline
    • xscale
    • xtickangle
    • xtickformat
    • xticklabels
    • xticks
    • ylabel
    • ylim
    • yline
    • yscale
    • ytickangle
    • ytickformat
    • yticklabels
    • yticks
    • zlabel
    • zlim
    • zoom

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

X
Type
NumericArray
Required
Yes
Description
Polygon X coordinates.
Y
Type
NumericArray
Required
Yes
Description
Polygon Y coordinates.
Z
Type
NumericArray
Required
Yes
Description
Polygon Z coordinates.
C
Type
Any
Required
Yes
Description
Color specification.
groups
Type
Any
Required
Variadic
Description
One or more `(X, Y, Z, C)` polygon groups.
props
Type
Any
Required
Variadic
Description
Trailing patch name/value property pairs.
ax
Type
AxesHandle
Required
Yes
Description
Target axes handle.
NameTypeRequiredDefaultDescription
XNumericArrayYes—Polygon X coordinates.
YNumericArrayYes—Polygon Y coordinates.
ZNumericArrayYes—Polygon Z coordinates.
CAnyYes—Color specification.
groupsAnyVariadic—One or more `(X, Y, Z, C)` polygon groups.
propsAnyVariadic—Trailing patch name/value property pairs.
axAxesHandleYes—Target axes handle.

Returns

h
Type
Any
Description
Handle or row-vector of handles for created patch objects.
NameTypeDescription
hAnyHandle or row-vector of handles for created patch objects.

Errors

RunMat:fill3:InvalidArgument
When
Input groups, axes targeting, or trailing property pairs are invalid.
Message
fill3: invalid argument
RunMat:fill3:Internal
When
Internal patch construction or rendering fails unexpectedly.
Message
fill3: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than one output is requested from a coordinate chart constructor.
Message
plotting: too many output arguments
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
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

fill3(X, Y, Z, C) creates one or more 3-D filled polygons from matching coordinate arrays.

Equal-length row or column vector coordinate inputs create one polygon regardless of orientation.

When any coordinate is a matrix, coordinate vectors matching its row count are shared across its columns; square matrices are deterministically grouped by columns.

Matrix coordinate inputs create one independently addressable Patch object per column and return one handle per column.

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.

Numeric C is retained as authoritative CData for indexed color mapping; color strings and RGB triples use the shared Patch color parser.

Integer XData, YData, ZData, and CData preserve their original class, exact values, and shape independently of renderer geometry.

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.

Rendering and residency

fill3 is a plotting sink. It gathers GPU-resident coordinate and CData inputs exactly through their owning providers, then lowers each vector or matrix column to an independent Patch object.

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.

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.

Declared source precision and class coverage

single

double

Coordinate broadcasting

none

Runtime contract and boundaries

Graphics results are host double handles; fill/fill3 may return a row of handles for independently created polygon columns/groups. Sphere instead supports zero through three requested outputs: statement form plots, while output forms return host double coordinate grids. Handle aliases, value-selected options and exact graphics receiver roles are resolved by Runtime, not guessed from scalar facts.

The existing numerical and geometry owners validate coordinates, integer controls, shapes and properties. Single/double and all eight integer source classes retain their native storage wherever the object has authoritative source properties; client geometry and renderer buffers are deliberate floating boundaries, not a promise of exact wide-integer pixel positions. There is no sparse/complex plotting implementation or numeric broadcasting promise here. Logical, scalar, vector, matrix, rank and empty admission follows each documented owner below rather than a universal coercion.

RuntimeOwned preparation retains the original BuiltinArguments through suspension and completion. Eligible direct GPU routes require the live owning provider, admitted precision/storage/shape, compatible exports and installed plotting device. NoAttempt means pre-effect inapplicability, not permission to swallow export, allocation, cancellation or emission errors. Existing provider errors are propagated and ingress errors are terminal Never replay. Source-property queries and figure persistence may require explicit owner-aware readback; surface property snapshots and quiver3/patch construction are not zero-copy routes.

Canonical UserInterface capability and host-callback effects reflect scene creation/presentation; function-sampling entries additionally declare Unknown effects for arbitrary user callbacks and require the Process execution stack. NativeAndWasm means the Runtime entry is portable, not that an absent graphics host is emulated. Portable Runtime linkage introduces no separate native numerical library artifact. Rendering is a fusion boundary and distributed execution is unsupported; no numeric provider kernel or fusion primitive is invented.

Chart scratch, metadata, retained render state and the sphere coordinate builder do not yet have complete finite host allocation ownership. The shared canonical HostAllocationReceipt policy guard refuses Managed work before extraction/gather/callbacks or scene mutation, preserves ordinary Unbounded routes, and checks captured cancellation generation and policy before publication. This is an explicit L25 gap, not allocation completion. Long synchronous geometry/copy loops, renderer/provider-private allocation accounting, full MATLAB property parity, physical performance and actual example execution remain independently required.

Supported representations and remaining forms

One or more X,Y,Z,C groups lower to independently addressable shared Patch objects, with leading axes and trailing shared properties retained. Vectors form one polygon; matched matrices split by columns, reusing row-count-compatible vectors. The result is a scalar handle or row of handles; standard 3-D view is applied even for z=0 polygons.

Shared Patch parsing owns FaceColor/EdgeColor, FaceAlpha/EdgeAlpha, LineWidth, DisplayName, Visible and color/indexed-CData behavior. Native X/Y/Z/C source class and shape remain authoritative. GPU coordinate/CData gathering precedes host polygon construction; no direct device polygon packer or full renderer color-mapping fidelity is fabricated. Typed-integer axes aliases retain their existing separate compatibility gate.

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

Rendered fill3 example

x1 = [0 1.3 0.2];
y1 = [0 0.2 1.1];
z1 = [0.2 0.5 1.2];
x2 = [1.5 2.8 2.6 1.4];
y2 = [0.1 0.1 1.1 1.2];
z2 = [1.0 1.0 1.7 1.7];
x3 = [0.4 1.2 0.8];
y3 = [1.5 1.7 2.6];
z3 = [0.4 1.3 0.8];

fill3(x1, y1, z1, [0.2 0.7 0.95], x2, y2, z2, [0.95 0.45 0.2], x3, y3, z3, [0.4 0.85 0.45]);
title('3-D Polygon Assembly');
xlabel('x');
ylabel('y');
zlabel('z');
view(38, 25);
grid on;
Expected output:
Three separated colored polygons rendered with MATLAB fill3 in RunMat

Compare this result with other chart types in the plot examples.

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?⌄

Yes. Numeric scalar, vector, and matrix C inputs are retained as Patch CData. Renderer colormap fidelity continues to share the Patch renderer implementation.

Related Plotting functions

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

addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom

More plotting resources

  • Graphics Handles
  • Plot replay and export

Source you can read

Every RunMat function's source is public. Read exactly how fill3 is executed, line by line, in Rust.

  • View the source for fill3 in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Options
  • Rendering and residency
  • Declared source precision and class coverage
  • Coordinate broadcasting
  • Runtime contract and boundaries
  • Supported representations and remaining forms
  • Examples
  • Create a red square in the z=0 plane
  • Create two filled polygons in one call
  • Apply patch properties to a fill3 polygon
  • Create one patch per matrix column
  • Rendered fill3 example
  • Using fill3 with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Source you can read
  • About RunMat