Control the display of plot grid lines.
The function state input may be either "on"
or "off"
.
If it is omitted, the current grid state is toggled.
When the first argument is "minor"
all subsequent commands
modify the minor grid rather than the major grid.
If the first argument hax is an axes handle, then operate on
this axis rather than the current axes returned by gca
.
To control the grid lines for an individual axis use the set
function. For example:
set (gca, "ygrid", "on");
See also: axis, box.
The following code
clf; subplot (3, 2, 1); plot (1:100); grid off; title ("grid off"); subplot (3, 2, 2); plot (1:100); grid on; title ("grid on"); subplot (3, 2, 3); plot (1:100); set (gca, "xgrid", "on"); title ("xgrid on"); subplot (3, 2, 4); plot (1:100); set (gca, "ygrid", "on"); title ("ygrid on"); subplot (3, 2, 5); plot (1:100); grid minor; title ("grid minor"); subplot (3, 2, 6); plot (1:100); set (gca, "yminorgrid", "on"); title ("yminorgrid on");
Produces the following figure
Figure 1 |
---|
The following code
subplot (2,2,1); semilogy (1:100); grid off; title ("grid off"); subplot (2,2,2); semilogy (1:100); grid on; title ("grid on"); subplot (2,2,3); semilogy (1:100); grid off; title ("no grid"); subplot (2,2,4); semilogy (1:100); grid minor; title ("grid minor");
Produces the following figure
Figure 1 |
---|
The following code
## Display minor grid lines at major ticks clf; subplot (1,2,1) plot (1:10); set (gca, "xminorgrid", "on"); set (gca, "yminorgrid", "on"); subplot (1,2,2) semilogy (1:100); set (gca, "xminorgrid", "on"); set (gca, "yminorgrid", "on");
Produces the following figure
Figure 1 |
---|
Package: octave