RunMat
GitHub

grid — Toggle axes grid lines in MATLAB and RunMat plotting.

grid controls visibility of major and minor axes grid lines on the active axes or subplot. Command forms such as grid on, grid off, grid minor, and toggle behavior follow MATLAB semantics.

Syntax

enabled = grid()
enabled = grid(mode)

Inputs

NameTypeRequiredDefaultDescription
modeStringScalarNo"toggle"Grid mode token ('on'|'off'|'minor').

Returns

NameTypeDescription
enabledLogicalArrayGrid enabled state after command execution.

Errors

IdentifierWhenMessage
RunMat:grid:InvalidArgumentGrid mode argument is unsupported.grid: invalid argument

How grid works

  • grid on enables grid lines on the current axes.
  • grid off disables major and minor grid lines on the current axes.
  • grid minor toggles minor grid lines without changing the major grid state.
  • Calling grid with no argument toggles the major grid state.
  • Grid visibility is subplot-local and does not spill into other axes automatically.

Examples

Enable grid lines on a simple line chart

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

Toggle minor grid lines on the current axes

plot(1:10, sin(1:10));
grid minor;

Toggle grid lines in one subplot only

subplot(1, 2, 1);
plot(1:5, 1:5);
grid off;
subplot(1, 2, 2);
plot(1:5, [5 4 3 2 1]);
grid on;

Using grid with coding agents

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

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

FAQ

Does RunMat support minor grid lines?

Yes. Use grid minor or grid('minor') to toggle minor grid lines on the active axes. grid off disables both major and minor grid lines.

Can I style the grid line color or width?

Grid styling is tied to axes properties. You can adjust the grid appearance through the axes handle with set(gca, 'GridColor', [0.5 0.5 0.5]) and related properties when the axes property path supports them. Check get(gca) to see what's currently exposed.

Does grid state carry across subplots?

No. Grid visibility is subplot-local. Calling grid on in one panel doesn't turn it on in others — you need to enable it explicitly in each subplot where you want grid lines.

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

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

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

More plotting resources

Open-source implementation

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