You are reading an old version of the documentation (v2.2.3). For the latest version see https://matplotlib.org/stable/api/_as_gen/matplotlib.axis.Axis.grid.html
Version 2.2.3
matplotlib
Fork me on GitHub

matplotlib.axis.Axis.grid

Axis.grid(b=None, which='major', **kwargs)[source]

Set the axis grid on or off; b is a boolean. Use which = 'major' | 'minor' | 'both' to set the grid for major or minor ticks.

If b is None and len(kwargs)==0, toggle the grid state. If kwargs are supplied, it is assumed you want the grid on and b will be set to True.

kwargs are used to set the line properties of the grids, e.g.,

xax.grid(color='r', linestyle='-', linewidth=2)