Axes.locator_params(axis='both', tight=None, **kwargs)[source]#

Control behavior of major tick locators.

Because the locator is involved in autoscaling, autoscale_view is called automatically after the parameters are changed.

axis{'both', 'x', 'y'}, default: 'both'

The axis on which to operate. (For 3D Axes, axis can also be set to 'z', and 'both' refers to all three axes.)

tightbool or None, optional

Parameter passed to autoscale_view. Default is None, for no change.

Other Parameters:

Remaining keyword arguments are passed to directly to the set_params() method of the locator. Supported keywords depend on the type of the locator. See for example set_params for the ticker.MaxNLocator used by default for linear.


When plotting small subplots, one might want to reduce the maximum number of ticks and use tight bounds, for example:

ax.locator_params(tight=True, nbins=4)

Examples using matplotlib.axes.Axes.locator_params#

Contourf demo

Contourf demo

Constrained Layout Guide

Constrained Layout Guide

Tight Layout guide

Tight Layout guide