Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #14019 on branch v3.1.x (Update docstring of locator_params()) #14074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2874,33 +2874,36 @@ def ticklabel_format(self, *, axis='both', style='', scilimits=None,

def locator_params(self, axis='both', tight=None, **kwargs):
"""
Control behavior of tick locators.
Control behavior of major tick locators.

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

Parameters
----------
axis : {'both', 'x', 'y'}, optional
The axis on which to operate.

tight : bool or None, optional
Parameter passed to :meth:`autoscale_view`.
Parameter passed to `~.Axes.autoscale_view`.
Default is None, for no change.

Other Parameters
----------------
**kw
**kwargs
Remaining keyword arguments are passed to directly to the
:meth:`~matplotlib.ticker.MaxNLocator.set_params` method.
``set_params()`` method of the locator. Supported keywords depend
on the type of the locator. See for example
`~.ticker.MaxNLocator.set_params` for the `.ticker.MaxNLocator`
used by default for linear axes.

Typically one might want to reduce the maximum number of ticks and use
tight bounds when plotting small subplots, for example::
Examples
--------
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)

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

This presently works only for the `~matplotlib.ticker.MaxNLocator` used
by default on linear axes, but it may be generalized.
"""
_x = axis in ['x', 'both']
_y = axis in ['y', 'both']
Expand Down