{
"title": "box",
"category": "plotting",
"keywords": [
"box",
"axes box",
"box on",
"box off",
"matlab box"
],
"summary": "Toggle axes box outlines for chart framing, presentation, and MATLAB `box on` / `box off` workflows.",
"requires_feature": null,
"tested": {
"unit": "builtins::plotting::cmds"
},
"description": "`box` controls whether the current axes draw their outer frame. Like MATLAB, RunMat supports `box on`, `box off`, and bare `box` toggling. This is mainly a presentation/state command, so it is usually used alongside `axis`, `grid`, and subplot-specific styling.",
"behaviors": [
"`box on` enables the axes frame on the current axes.",
"`box off` disables the axes frame on the current axes.",
"Calling `box` with no argument toggles the current state.",
"Box state is subplot-local and applies to the currently active axes."
],
"examples": [
{
"description": "Turn the axes frame on for a chart",
"input": "plot(1:5, [1 4 2 5 3]);\nbox on;"
},
{
"description": "Style subplots independently",
"input": "subplot(1, 2, 1);\nplot(1:5, 1:5);\nbox off;\nsubplot(1, 2, 2);\nplot(1:5, [5 4 3 2 1]);\nbox on;"
}
],
"faqs": [
{
"question": "When should I turn the box off?",
"answer": "Turn `box off` for a cleaner, more modern chart style — especially for presentations or publications where the top and right frame edges add visual noise without carrying data. Many style guides prefer open axes (left + bottom only) for scatter plots and line charts."
},
{
"question": "Does box interact with grid or axis settings?",
"answer": "`box`, `grid`, and `axis` are independent axes-state commands. Turning `box off` removes the outer frame but doesn't touch grid lines or axis limits. You can combine them freely: `box off; grid on; axis tight;` is a common clean-chart recipe."
}
],
"links": [
{
"label": "axis",
"url": "./axis"
},
{
"label": "grid",
"url": "./grid"
},
{
"label": "subplot",
"url": "./subplot"
},
{
"label": "Choosing the right plot type",
"url": "/docs/plotting/choosing-the-right-plot-type"
},
{
"label": "Styling plots and axes",
"url": "/docs/plotting/styling-plots-and-axes"
},
{
"label": "Plot replay and export",
"url": "/docs/plotting/plot-replay-and-export"
},
{
"label": "Complete plotting guide",
"url": "/blog/matlab-plotting-guide"
}
],
"source": {
"label": "`crates/runmat-runtime/src/builtins/plotting/ops/cmds.rs`",
"url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/plotting/ops/cmds.rs"
}
}