fill — Create filled 2-D polygon patches.
fill(X,Y,C) creates filled polygonal regions as Patch graphics. Integer coordinate and CData classes remain authoritative on the Patch object; conversion to renderer geometry is an explicit client-side boundary.
Syntax
p = fill(X, Y, C, ..., Name, Value)Inputs
arguments- Type
Any- Required
- Variadic
- Description
- One or more X,Y,C groups followed by Patch name/value properties.
Returns
p- Type
Any- Description
- Patch handle or row vector of patch handles.
Errors
RunMat:fill:InvalidArgument- When
- Coordinate/color groups, axes targeting, or properties are invalid.
- Message
fill: invalid argument
RunMat:plotting:TooManyOutputs- When
- More than one output is requested from a coordinate chart constructor.
- Message
plotting: too many output arguments
Behavior
Equal-length row or column vector X and Y inputs create one region regardless of orientation; matrix inputs create independently addressable regions from columns.
When either coordinate is a matrix, an equal-length coordinate vector matching the matrix row count is shared across every matrix column; square matrices are grouped by columns.
Multiple X,Y,C groups create multiple Patch graphics.
C accepts color text, RGB triples, or numeric indexed color data.
XData, YData, and CData preserve the original numeric class and shape.
A leading axes handle targets an existing axes; typed-integer numeric aliases are available only when RunMat extensions are enabled.
Rendering and residency
GPU-resident inputs gather exactly through their owning provider and Patch construction executes on the client.
Numeric provider precision frontier
fill declares no direct numeric provider precision list; host generation/sampling or owner-aware gather and installed graphics rendering are separate boundaries.
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,C groups create Patch objects; a leading axes target and trailing shared Patch properties apply to every group. Equal-length row/column vectors form one polygon; matrix inputs split by columns and a vector matching the matrix row count is reused across columns. A single polygon returns one handle, multiple groups/columns a row of handles. Colors can be text/RGB or authoritative indexed CData.
Coordinates/color data retain native class, exact values and original shape independently of renderer geometry. Shared Patch grouping gathers GPU sources through their owner and validates matching lengths/matrix geometry before polygon construction. Integer numeric axes aliases are separately gated; they are not ordinary documented axes objects. Complex/sparse input and full Patch renderer colormap fidelity remain existing frontiers, not a new alternative storage representation.
Examples
Create a filled triangle
h = fill([0 1 0], [0 0 1], 'red');Expected output:
h is a Patch graphics handleUse exact integer coordinates and indexed color data
h = fill(uint64([0 1 0]), uint64([0 0 1]), uint8(1));Expected output:
get(h,'XData') retains class uint64Create one independently addressable Patch per matrix column
X = uint64([0 2; 1 3; 0 2]);
Y = uint64([0 0; 0 0; 1 1]);
C = uint16([1 4; 2 5; 3 6]);
h = fill(X,Y,C);Expected output:
h is a two-element Patch handle vector; each handle retains its column's typed XData, YData, and CDataUsing fill with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how fill changes the result.
Run a small fill example, explain the result, then change one input and compare the output.
FAQ
Is fill an array-construction function?⌄
No. MATLAB-compatible fill creates Patch graphics. Use createArray to construct constant-valued arrays.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill3 · 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
Source you can read
Every RunMat function's source is public. Read exactly how fill is executed, line by line, in Rust.
- View the source for fill 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.