publiplots.add_grid#
- publiplots.add_grid(ax, which='major', axis='both', alpha=None, linestyle=None, linewidth=None, color=None, zorder=0)[source]#
Add customizable gridlines to axes.
Also sets
ax.set_axisbelow(True)so the grid renders beneath data artists.- Parameters:
ax (matplotlib.axes.Axes) – Axes to modify in place.
which ({‘major’, ‘minor’, ‘both’}, default
'major') – Which tick gridlines to show.axis ({‘x’, ‘y’, ‘both’}, default
'both') – Which axis to add gridlines to.alpha (float, optional) – Gridline transparency in
[0, 1]. Defaults torcParams['grid.alpha'].linestyle (str, optional) – Matplotlib linestyle spec. Defaults to
rcParams['grid.linestyle'].linewidth (float, optional) – Gridline width (points). Defaults to
rcParams['grid.linewidth'].color (str, optional) – Gridline color. Defaults to
rcParams['grid.color'].zorder (int, default
0) – Gridline z-order (lower values render behind other elements).
Examples
Add default gridlines:
>>> pp.add_grid(ax)Add only horizontal gridlines:
>>> pp.add_grid(ax, axis='y')Customize grid appearance:
>>> pp.add_grid(ax, alpha=0.5, linestyle=':', color='steelblue')