publiplots.add_grid¶
- publiplots.add_grid(ax, which='major', axis='both', alpha=0.3, linestyle='--', linewidth=0.5, color='0.8', 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, default
0.3) – Gridline transparency in[0, 1].linestyle (str, default
'--') – Matplotlib linestyle spec.linewidth (float, default
0.5) – Gridline width (points).color (str, default
'0.8') – Gridline 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')