RunMat
GitHub

figure — Create a new figure or select an existing figure handle.

figure creates or selects the active plotting figure. With no arguments it allocates a fresh figure handle and makes that figure current. Passing a positive numeric handle selects that figure, creating it if it does not already exist. Passing 'next' is equivalent to asking for a fresh figure.

How figure works

  • figure() creates a new figure and returns its numeric handle.
  • figure(n) selects figure n. If that handle does not exist yet, RunMat creates it.
  • figure('next') creates a new figure instead of selecting an existing one.
  • The selected figure becomes the target for subsequent plotting commands such as plot, subplot, gca, clf, and hold.

How RunMat runs figure on the GPU

figure performs no provider dispatch. GPU-resident arrays passed to later plotting calls may still remain on device when the renderer supports that path.

GPU memory and residency

figure only updates plotting state and returns a host-side numeric handle. It does not affect array residency.

Examples

Create a fresh figure

f = figure()

Expected output:

% f is a positive numeric figure handle

Create another figure with the explicit 'next' selector

f1 = figure();
f2 = figure("next")

Expected output:

% f2 is a different figure handle from f1

Select a specific figure handle

figure(3);
plot(1:5, [1 4 2 5 3]);

Expected output:

% plotting now targets figure 3

FAQ

Does figure(n) require the handle to exist already?

No. RunMat selects figure n, creating it on demand if necessary.

What does figure('next') do?

It forces creation of a new figure rather than reusing an existing handle.

Does figure draw anything by itself?

No. It only manages the active figure selection. Plotting happens when you call builtins like plot, scatter, or surf.

2D Charts

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

3D & Surface

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

cla · clf · hold · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how figure 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 for free

Write code or describe what you want to compute. The sandbox is free, no account required.