hold — Control whether new plots replace or append to the current axes.
hold controls whether subsequent plotting commands append to the current axes or replace existing plot objects. The state is tracked per axes, so different subplots can have different hold settings.
How hold works
hold()toggles the current hold state.hold('on')enables appending to the current axes.hold('off')disables appending so later plots replace the axes contents.hold('all')is currently treated the same ashold('on').- Logical and numeric scalar inputs are accepted: zero means off and nonzero means on.
How RunMat runs hold on the GPU
hold performs no provider dispatch; it updates per-axes plotting state in the host-side registry.
GPU memory and residency
hold only mutates plotting state and does not affect array residency.
Examples
Append a second line to the same axes
x = 0:0.1:1;
plot(x, x);
hold on;
plot(x, x.^2);Expected output:
% both lines remain visible on the current axesDisable appending again
hold off;
plot(1:5, [5 4 3 2 1]);Expected output:
% the new plot replaces the previous axes contentsToggle hold state programmatically
state1 = hold();
state2 = hold();Expected output:
% state1 and state2 reflect the toggled boolean stateFAQ
Is hold state per figure or per axes?
It is tracked per axes, so one subplot can be in hold mode while another is not.
What does hold('all') do?
RunMat currently treats 'all' the same as 'on'.
What does the return value mean?
It is the resulting boolean hold state after applying the command.
Related Plotting functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how hold works, line by line, in Rust.
- View hold.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.