grid
grid on|off/grid minor [off](bare command)
Input: bare command · Output: no output
What it is
on/off toggles major gridlines. minor/minor off independently toggles dotted minor gridlines (MATLAB allows minor grid without major grid too, so this never forces major grid on). Calling grid(...) as a function is accepted but is a no-op — only the bare command form actually changes anything.
Overloads
2 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.
| Code | Input | Output | Description |
grid on|off / grid minor [off] (bare command) | bare command —not documented yet | no output | grid off (bare) is the real toggle — it actually removes the panel's gridlines. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
t = linspace(0, 1, 50)
plot(t, sin(t))
grid off
· plot: figure 6 (50 points)
| Code | Input | Output | Description |
grid on|off / grid minor [off] (bare command) | bare command —not documented yet | no output | grid(...) called with parentheses, as a function, is accepted so a MATLAB-style script still parses — but it changes nothing. Calling it after grid off does not turn the grid back on; the gridlines stay off, exactly as grid off left them. |
Examples
Written for this form and run by the build -- the output below is what the engine actually produced.
t = linspace(0, 1, 50)
plot(t, sin(t))
grid off
grid() # no-op -- gridlines stay off, not re-enabled
· plot: figure 7 (50 points)
These figure/axes calls are meant to be composed, not used one at a time, so here is a single panel exercising most of the row above: it renames the tick positions to words instead of numbers on both axes, swaps the figure's font and background, turns on the (currently non-drawing) colormap/colorbar pair, and explicitly restates grid/box/scale even though they are already at their defaults, to show that calling them is always safe. Run it and look at the labels — "start"/"mid"/"end" and "low"/"zero"/"high" should sit exactly where 0, 0.5, 1 and -1, 0, 1 used to, against a warm off-white page instead of pure white:
figure()
t = linspace(0, 1, 200)
plot(t, sin(2 * pi * 5 * t))
xticks([0, 0.5, 1])
xticklabels("start", "mid", "end")
yticks([-1, 0, 1])
yticklabels("low", "zero", "high")
fontfamily("sans")
fontsize(tick = 10, label = 12, title = 14)
figure_background("#f7f7f7")
colormap("viridis")
colorbar()
grid()
box()
subplot(1, 1, 1)
xscale("linear")
yscale("linear")
title("Styled panel")
· plot: figure 8 (200 points)
How it works
grid on/grid off toggles the major gridlines; grid minor/grid minor off toggles dotted minor gridlines independently (MATLAB allows minor grid without major grid too, so this doesn't force show_grid on).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.