RunMat
GitHub

hold — Control plot replacement versus appending in MATLAB and RunMat.

hold controls whether new plotting commands append to the current axes or replace existing plot objects. Per-axes hold state and command forms follow MATLAB semantics.

Syntax

enabled = hold()
enabled = hold(mode)

Inputs

NameTypeRequiredDefaultDescription
modeAnyNo"toggle"Hold mode ('on'|'off'|'all') or numeric/logical scalar.

Returns

NameTypeDescription
enabledLogicalArrayTrue when hold is enabled after command execution.

Errors

IdentifierWhenMessage
RunMat:hold:InvalidArgumentHold mode argument is unsupported.hold: invalid argument

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 as hold('on').
  • Logical and numeric scalar inputs are accepted: zero means off and nonzero means on.

Does RunMat run 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 axes

Disable appending again

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

Expected output:

% the new plot replaces the previous axes contents

Toggle hold state programmatically

state1 = hold();
state2 = hold();

Expected output:

% state1 and state2 reflect the toggled boolean state

Using hold with coding agents

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

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

FAQ

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.

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 · clf · figure · fill3 · patch · print · suptitle · xline · yline

Open-source implementation

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