RunMat
GitHub

clf — Clear figure contents in MATLAB and RunMat plotting.

clf clears the contents of the current figure while leaving the figure handle itself alive. It also accepts explicit figure handles and the 'all' selector, consistent with MATLAB and RunMat plotting behavior.

Syntax

result = clf()
result = clf(targets...)

Inputs

NameTypeRequiredDefaultDescription
targetsAnyVariadicFigure handle(s) or mode tokens ('all', 'reset').

Returns

NameTypeDescription
resultNumericScalarCleared handle for single-target calls or count for multi/all clears.

Errors

IdentifierWhenMessage
RunMat:clf:InvalidArgumentOne or more clear targets are invalid.clf: invalid argument
RunMat:clf:InternalInternal figure clear operation fails.clf: internal operation failed

How clf works

  • clf() clears the current figure.
  • clf(handle) clears the specified figure handle.
  • clf('all') clears every known figure and returns the number of figures that were cleared.
  • clf(handle1, handle2, ...) clears multiple figures and returns the number cleared when more than one handle is supplied.
  • clf('reset') is currently treated the same as plain clf.

Does RunMat run clf on the GPU?

clf performs no provider dispatch; it clears figures from the plotting registry and renderer state.

GPU memory and residency

clf only mutates plotting state and does not affect array residency.

Examples

Clear the current figure after plotting

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

Expected output:

% out is the cleared figure handle

Clear a specific figure by handle

figure(3);
plot(1:5, 1:5);
out = clf(3)

Expected output:

out = 3

Clear every figure

figure(1); plot(1:5, 1:5);
figure(2); plot(1:5, [5 4 3 2 1]);
count = clf("all")

Expected output:

count = 2

Using clf with coding agents

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

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

FAQ

Does clf delete the figure handle itself?

No. It clears the figure contents but keeps the figure handle selected and available.

What does clf('reset') do today?

RunMat parses the keyword for compatibility, but the current implementation treats it the same as plain clf.

What does clf('all') return?

It returns the number of figures that were cleared. When no figures exist, it returns 0.

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 · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · figure · fill3 · hold · patch · print · suptitle · xline · yline

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 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.