Grid

The set grid command allows grid lines to be drawn on the plot.

Syntax:

     set grid {{no}{m}xtics} {{no}{m}ytics} {{no}{m}ztics}
              {{no}{m}x2tics} {{no}{m}y2tics} {{no}{m}rtics}
              {{no}{m}cbtics}
              {polar {<angle>}}
              {layerdefault | front | back}
              {{no}vertical}
              {<line-properties-major> {, <line-properties-minor>}}
     unset grid
     show grid

The grid can be enabled and disabled for the major and/or minor tic marks on any axis, and the linetype and linewidth can be specified for major and minor grid lines, also via a predefined linestyle, as far as the active terminal driver supports this (see set style line (p. [*])).

A polar grid can be drawn for 2D plots. This is the default action of set grid if the program is already in polar mode, but can be enabled explicitly by set grid polar 4#4angle5#5 rtics whether or not the program is in polar mode. Circles are drawn to intersect major and/or minor tics along the r axis, and radial lines are drawn with a spacing of 4#4angle5#5. Tic marks around the perimeter are controlled by set ttics, but these do not produce radial grid lines.

The pertinent tics must be enabled before set grid can draw them; gnuplot will quietly ignore instructions to draw grid lines at non-existent tics, but they will appear if the tics are subsequently enabled.

If no linetype is specified for the minor gridlines, the same linetype as the major gridlines is used. The default polar angle is 30 degrees.

If front is given, the grid is drawn on top of the graphed data. If back is given, the grid is drawn underneath the graphed data. Using front will prevent the grid from being obscured by dense data. The default setup, layerdefault, is equivalent to back for 2D plots. In 3D plots the default is to split up the grid and the graph box into two layers: one behind, the other in front of the plotted data and functions. Since hidden3d mode does its own sorting, it ignores all grid drawing order options and passes the grid lines through the hidden line removal machinery instead. These options actually affect not only the grid, but also the lines output by set border and the various ticmarks (see set xtics (p. [*])).

In 3D plots grid lines at x- and y- axis tic positions are by default drawn only on the base plane parallel to z=0. The vertical keyword activates drawing grid lines in the xz and yz planes also, running from zmin to zmax.

Z grid lines are drawn on the bottom of the plot. This looks better if a partial box is drawn around the plot — see set border (p. [*]).