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

subplot — Select subplot grid locations to create multi-panel axes layouts with MATLAB-compatible subplot behavior.

subplot(m, n, p) selects or creates an axes position inside an m-by-n figure grid and returns its handle. It follows MATLAB-compatible subplot indexing and current-axes selection behavior.

Syntax

ax = subplot(rows, cols, position)

Inputs

rows
Type
SizeArg
Required
Yes
Description
Number of subplot rows.
cols
Type
SizeArg
Required
Yes
Description
Number of subplot columns.
position
Type
SizeArg
Required
Yes
Description
1-based subplot position in row-major order.
NameTypeRequiredDefaultDescription
rowsSizeArgYes—Number of subplot rows.
colsSizeArgYes—Number of subplot columns.
positionSizeArgYes—1-based subplot position in row-major order.

Returns

ax
Type
NumericScalar
Description
Encoded handle for the selected subplot axes.
NameTypeDescription
axNumericScalarEncoded handle for the selected subplot axes.

Errors

RunMat:subplot:InvalidArgument
When
Rows/cols/position are unsupported, non-scalar, non-finite, or non-positive.
Message
subplot: invalid argument
RunMat:subplot:IndexOutOfRange
When
Position is outside the configured subplot grid.
Message
subplot: subplot index is out of range for the grid
RunMat:subplot:Internal
When
Internal subplot state operation fails.
Message
subplot: internal operation failed
RunMat:subplot:TooManyOutputs
When
More than one output is requested.
Message
subplot: at most one output is supported
IdentifierWhenMessage
RunMat:subplot:InvalidArgumentRows/cols/position are unsupported, non-scalar, non-finite, or non-positive.subplot: invalid argument
RunMat:subplot:IndexOutOfRangePosition is outside the configured subplot grid.subplot: subplot index is out of range for the grid
RunMat:subplot:InternalInternal subplot state operation fails.subplot: internal operation failed
RunMat:subplot:TooManyOutputsMore than one output is requested.subplot: at most one output is supported

Behavior and compatibility

The returned value is an axes handle that can be passed explicitly to later plotting commands.

Subplot-local metadata stays isolated per axes: titles, legends, limits, log modes, and 3-D view state are all tracked independently.

Subsequent plotting commands operate on the selected subplot unless another axes handle is passed explicitly.

Indices are one-based in the MATLAB style. subplot(2, 2, 3) selects the third slot in row-major order.

The documented grid controls use single or double values. RunMat can additionally parse typed-integer scalar controls exactly when RunMat extensions are enabled; strict compatibility mode rejects that extra form before changing figure state.

Placement

Graphics state remains host-owned. Resident control values reject before provider access; resident plotted arrays retain the rendering pipeline.

Whole-call resource accounting, cooperative large host controls, and native/browser presentation require integrated qualification.

Examples

Create a 2x2 subplot layout

subplot(2, 2, 1);
plot(0:0.1:1, (0:0.1:1).^2);
subplot(2, 2, 2);
scatter(1:5, [5 4 3 2 1]);

Capture and reuse an axes handle explicitly

ax = subplot(1, 2, 2);
plot(ax, 0:0.1:1, sin(0:0.1:1));
get(ax, 'Type')

Expected output:

ans =
    'axes'

Show that subplot-local state stays isolated caption: % Only the first subplot uses a logarithmic x-axis

subplot(1, 2, 1);
semilogx(logspace(0, 2, 50), logspace(0, 2, 50));
subplot(1, 2, 2);
plot(1:5, 1:5);

Using subplot with coding agents

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

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

FAQ

How do I control the number of rows and columns in a subplot layout?⌄

The first two arguments to subplot(m, n, p) set the grid dimensions: m rows and n columns. The third argument p selects which slot to activate, counted in row-major order starting at 1. subplot(3, 1, 2) gives you the middle row of a three-row single-column layout.

Can two subplots share the same x-axis range?⌄

Set matching limits on both axes manually with axis or set. RunMat also provides linkaxes for supported linked-axis groups; explicit matching limits remain available as illustrated below.

subplot(2, 1, 1); plot(0:10, rand(1, 11)); axis([0 10 0 1]);
subplot(2, 1, 2); plot(0:10, rand(1, 11)); axis([0 10 0 1]);
Can I make subplots of unequal sizes?⌄

No. This implementation requires a scalar subplot position; vector positions that span multiple grid slots are not supported. Use separate scalar positions to create the individual panels. A vector position is rejected before configuring the subplot.

Can the grid controls be typed integers?⌄

The compatibility surface documents single and double controls. If RunMat extensions are enabled, all eight native integer scalar classes are also accepted and parsed exactly; strict compatibility mode rejects that extra form.

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

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 and compatibility
  • Placement
  • Examples
  • Create a 2x2 subplot layout
  • Capture and reuse an axes handle explicitly
  • Show that subplot-local state stays isolated caption: % Only the first subplot uses a logarithmic x-axis
  • Using subplot with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • About RunMat