Navigation

Operators and Keywords

Function List:

C++ API

Command: grid
Command: grid on
Command: grid off
Command: grid minor
Command: grid minor on
Command: grid minor off
Function File: grid (hax, …)

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.

Demonstration 1

The following code

 clf;
 subplot (2,2,1);
  plot (1:100);
  grid off;
  title ('no grid');
 subplot (2,2,2);
  plot (1:100);
  grid on;
  title ('grid on');
 subplot (2,2,3);
  plot (1:100);
  grid off;
  title ('no grid');
 subplot (2,2,4);
  plot (1:100);
  grid minor;
  title ('grid minor');

Produces the following figure

Figure 1

Demonstration 2

The following code

 subplot (2,2,1);
  semilogy (1:100);
  grid off;
  title ('no grid');
 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

Package: octave