RunMat
GitHub

subplot — Split a figure into subplot grids for multi-panel charts, side-by-side comparisons, and MATLAB subplot workflows.

subplot(m, n, p) selects an axes location inside an m by n figure grid and returns an axes handle for that slot. In RunMat, subplot selection is the backbone for axes-local plot state: legends, labels, log modes, view angles, and plot children all attach to the currently selected subplot unless an explicit handle is passed.

How subplot works in RunMat

  • 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.

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

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

Expected output:

% Only the first subplot uses a logarithmic x-axis

These functions work well alongside subplot. Each page has runnable examples you can try in the browser.

plot, legend, get, set

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how subplot works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat — free, no sign-up

Start running MATLAB code immediately in your browser.