clf — Clear the contents of the current figure, selected figure handles, or all figures.
clf clears the contents of the current figure while keeping the figure handle itself alive. RunMat also accepts explicit figure handles and the 'all' selector to clear multiple figures. The compatibility keyword 'reset' is currently parsed but behaves the same as plain clf.
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 plainclf.
How RunMat runs 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 handleClear a specific figure by handle
figure(3);
plot(1:5, 1:5);
out = clf(3)Expected output:
out = 3Clear 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 = 2FAQ
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.
Related Plotting functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how clf works, line by line, in Rust.
- View clf.rs on GitHub
- Learn how the runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.