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

contourf — Create filled contour plots in MATLAB and RunMat.

contourf creates filled contour plots by coloring regions between contour levels. RunMat returns an opaque contour-fill handle; MATLAB's contour-matrix first output and two-output [M, c] form remain graphics-representation gaps.

Syntax

h = contourf(Z)
h = contourf(Z, V)
h = contourf(Z, Name, Value, ...)
h = contourf(Z, V, Name, Value, ...)
h = contourf(X, Y, Z)
h = contourf(X, Y, Z, V)
h = contourf(X, Y, Z, V, Name, Value, ...)
h = contourf(ax, ...)

Inputs

Z
Type
NumericArray
Required
Yes
Description
Contour height grid.
V
Type
Any
Required
Yes
Description
Contour level count/value vector.
props
Type
Any
Required
Variadic
Description
Name/value contour options.
X
Type
NumericArray
Required
Yes
Description
X coordinate vector matching Z columns or coordinate matrix matching Z.
Y
Type
NumericArray
Required
Yes
Description
Y coordinate vector matching Z rows or coordinate matrix matching Z.
ax
Type
Any
Required
Yes
Description
Target axes object.
args
Type
Any
Required
Variadic
Description
Any supported filled-contour data, level, line-specification, and property arguments.
NameTypeRequiredDefaultDescription
ZNumericArrayYes—Contour height grid.
VAnyYes—Contour level count/value vector.
propsAnyVariadic—Name/value contour options.
XNumericArrayYes—X coordinate vector matching Z columns or coordinate matrix matching Z.
YNumericArrayYes—Y coordinate vector matching Z rows or coordinate matrix matching Z.
axAnyYes—Target axes object.
argsAnyVariadic—Any supported filled-contour data, level, line-specification, and property arguments.

Returns

h
Type
NumericScalar
Description
Handle to filled contour plot.
NameTypeDescription
hNumericScalarHandle to filled contour plot.

Errors

RunMat:contourf:InvalidArgument
When
Contour input arrays, level arguments, or name/value options are invalid.
Message
contourf: invalid argument
RunMat:contourf:Internal
When
Internal filled-contour render preparation fails unexpectedly.
Message
contourf: 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:contourf:InvalidArgumentContour input arrays, level arguments, or name/value options are invalid.contourf: invalid argument
RunMat:contourf:InternalInternal filled-contour render preparation fails unexpectedly.contourf: internal operation failed
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

contourf(Z) uses implicit axes, contourf(X, Y, Z) accepts strictly monotonic coordinate vectors or coordinate matrices that vary along opposite dimensions, and contourf(ax, ...) selects an existing axes target.

All eight built-in integer classes are documented for X, Y, Z, positional level counts/vectors, LevelList, and LevelStep; RunMat also accepts them for positive LineWidth values. Shape, distinctness, coordinate-matrix identity, ordering, count, and scalar constraints are checked from authoritative storage before floating graphics conversion.

The returned value is a contour-fill handle in the plotting object system.

A scalar level is a positive bounded requested level count, a vector is an explicit monotonically increasing level list, and [k k] requests one level at k.

contourf works naturally with colorbar and colormap because filled regions are fundamentally color-mapped scalar ranges.

The public compatibility surface accepts GPU arrays but executes on the client. Resident integer inputs therefore gather through their owning provider, while RunMat additionally accelerates eligible floating Z grids through its shared WGPU plotting context.

Typed-integer LineColor RGB triplets containing only exact 0/1 channels use the separately gated contour-integer-line-color RunMat extension.

The broader Contour property surface, contour labels, post-construction typed data mutation, and MATLAB contour-matrix/object output forms remain general graphics gaps.

Rendering and residency

Eligible floating Z grids can use RunMat's shared WGPU filled-contour path. Integer gpuArray coordinates, heights, levels, and scalar properties gather exactly through their owning provider before the client graphics boundary because the contour shaders consume floating buffers.

Declared source precision and class coverage

single

double

int8

int16

int32

int64

uint8

uint16

uint32

uint64

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

Core forms are Z; Z plus level count/vector; X,Y,Z plus optional levels; leading axes; optional LineSpec followed by name/value pairs. Z must be at least 2-by-2 and nonconstant after the existing contour validation. Coordinate vectors are strictly monotonic; meshgrid-style coordinate matrices must have the correct identity and varying dimensions. Empty, mismatched or degenerate grids fail rather than becoming an invented 1-by-1 field.

Level counts are positive finite whole scalars subject to the existing one-million-level materialization ceiling. Explicit levels are strictly increasing, with [k k] representing a single level. LevelStep is positive finite; LineWidth is positive finite. Levels/LevelList, LevelStep, LineColor/Color, LineWidth and the existing LevelListMode controls use one shared parser. Integer order/count/meshgrid checks precede floating conversion; integer RGB 0/1 channels use the existing separately gated contour extension.

The returned value is the RunMat graphics handle, not MATLAB contour-matrix M or [M,c] output. Full contour labels, broad properties and post-construction coordinate mutation remain gaps. Eligible floating Z can use prepared GPU contours; axes/control reads and integer grids gather through their actual owner. A prepared composite publishes its requested parts only after their construction succeeds; errors are not fallback signals.

Contourf constructs filled regions plus the requested contour overlay through the shared prepared-input owner. LineColor none suppresses the overlay, not the filled regions. The returned contour-fill object reports Type contour; documented MATLAB contour-matrix outputs remain unimplemented.

Examples

Create a filled contour plot

[X, Y] = meshgrid(-2:0.25:2, -2:0.25:2);
Z = X .* exp(-X.^2 - Y.^2);
contourf(X, Y, Z);
colorbar;

Use explicit levels with a colormap

[X, Y] = meshgrid(-3:0.2:3, -3:0.2:3);
Z = cos(X) .* sin(Y);
contourf(X, Y, Z, [-0.75 -0.25 0 0.25 0.75]);
colormap('turbo');

Inspect the returned contour-fill handle

[X, Y] = meshgrid(1:20, 1:20);
Z = X - Y;
h = contourf(X, Y, Z);
get(h, 'Type')

Expected output:

ans =
    'contour'

Filled scalar field with explicit levels

[X, Y] = meshgrid(linspace(-3, 3, 150), linspace(-3, 3, 150));
Z = sin(X) .* cos(Y) + 0.5*sin(2*X + Y);

contourf(X, Y, Z, 25);
colormap('turbo');
colorbar;
title('Interference Pattern — Filled Contours');
xlabel('x');
ylabel('y');
axis equal;

Rendered contourf example

[X, Y] = meshgrid(linspace(-3, 3, 150), linspace(-3, 3, 150));
Z = sin(X) .* cos(Y) + 0.5*sin(2*X + Y);

contourf(X, Y, Z, 25);
colormap('turbo');
colorbar;
title('Interference Pattern - Filled Contours');
xlabel('x');
ylabel('y');
axis equal;
Expected output:
Synthetic interference field rendered as filled MATLAB contours in RunMat

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

Using contourf with coding agents

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

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

FAQ

What's the difference between contourf and contour?⌄

contourf fills the regions between contour levels with solid colors from the colormap. contour draws only the boundary lines. If you're building a heatmap-style visualization where color bands carry meaning, contourf is the right choice. If you just need iso-lines overlaid on something else, use contour.

How does the colormap interact with contourf?⌄

Each filled region maps to a range in the active colormap based on its contour level. Calling colormap('hot') after contourf recolors all regions immediately. Pair it with colorbar to show the value-to-color mapping.

contourf(X, Y, Z, 15);
colormap('hot');
colorbar;
How do I control the number of filled levels?⌄

Pass an integer as the fourth argument to set the level count: contourf(X, Y, Z, 20) creates 20 levels. For exact control, pass a vector of level values instead: contourf(X, Y, Z, [-1 -0.5 0 0.5 1]). More levels give smoother color transitions but add rendering cost on large grids.

Related Plotting functions

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · 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 · 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

More plotting resources

  • Choosing the right plot type
  • Styling plots and axes
  • Plot replay and export
  • Complete plotting guide

Source you can read

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

  • View the source for contourf 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
  • Rendering and residency
  • Declared source precision and class coverage
  • Coordinate broadcasting
  • Runtime contract and boundaries
  • Supported representations and remaining forms
  • Examples
  • Create a filled contour plot
  • Use explicit levels with a colormap
  • Inspect the returned contour-fill handle
  • Filled scalar field with explicit levels
  • Rendered contourf example
  • Using contourf 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