grid — Toggle grid lines for charts, subplots, and MATLAB grid on / grid off workflows.
grid controls the visibility of axes grid lines on the active subplot or axes selection. It supports the familiar MATLAB command-style forms grid on, grid off, and bare grid toggling, while returning the resulting boolean state in RunMat.
How grid works in RunMat
grid onenables grid lines on the current axes.grid offdisables grid lines on the current axes.- Calling
gridwith no argument toggles the current 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 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;FAQ
Does RunMat support minor grid lines?
Not yet — grid on enables major grid lines only. Minor grid support (the MATLAB grid minor form) is planned. For now, you get the primary tick grid, which covers most use cases.
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.
Related functions to explore
These functions work well alongside grid. Each page has runnable examples you can try in the browser.
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how grid works, line by line, in Rust.
- View grid.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.