Next: , Previous: functions, Up: set-show


3.24.26 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}cbtics}
                    {polar {<angle>}}
                    {layerdefault | front | back}
                    { {linestyle <major_linestyle>}
                      | {linetype | lt <major_linetype>}
                        {linewidth | lw <major_linewidth>}
                      { , {linestyle | ls <minor_linestyle>}
                          | {linetype | lt <minor_linetype>}
                            {linewidth | lw <minor_linewidth>} } }
           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.

Additionally, a polar grid can be selected for 2D plots—circles are drawn to intersect the selected tics, and radial lines are drawn at definable intervals. (The interval is given in degrees or radians, depending on the angles setting.) Note that a polar grid is no longer automatically generated in polar mode.

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 border and the various ticmarks (see `set xtics`).

Z grid lines are drawn on the bottom of the plot. This looks better if a partial box is drawn around the plot—see border.