Skip to content

Commit d3144b1

Browse files
authored
Improve Locator docstrings (matplotlib#27686)
* Improve Locator docstrings * Minor improvements to Locator docstrings
1 parent 2d2b113 commit d3144b1

File tree

1 file changed

+52
-54
lines changed

1 file changed

+52
-54
lines changed

lib/matplotlib/ticker.py

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ def symbol(self, symbol):
15891589

15901590
class Locator(TickHelper):
15911591
"""
1592-
Determine the tick locations;
1592+
Determine tick locations.
15931593
15941594
Note that the same locator should not be used across multiple
15951595
`~matplotlib.axis.Axis` because the locator stores references to the Axis
@@ -1679,10 +1679,10 @@ def view_limits(self, vmin, vmax):
16791679

16801680
class IndexLocator(Locator):
16811681
"""
1682-
Place a tick on every multiple of some base number of points
1683-
plotted, e.g., on every 5th point. It is assumed that you are doing
1684-
index plotting; i.e., the axis is 0, len(data). This is mainly
1685-
useful for x ticks.
1682+
Place ticks at every nth point plotted.
1683+
1684+
IndexLocator assumes index plotting; i.e., that the ticks are placed at integer
1685+
values in the range between 0 and len(data) inclusive.
16861686
"""
16871687
def __init__(self, base, offset):
16881688
"""Place ticks every *base* data point, starting at *offset*."""
@@ -1708,12 +1708,12 @@ def tick_values(self, vmin, vmax):
17081708

17091709
class FixedLocator(Locator):
17101710
"""
1711-
Tick locations are fixed at *locs*. If *nbins* is not None,
1712-
the *locs* array of possible positions will be subsampled to
1713-
keep the number of ticks <= *nbins* +1.
1714-
The subsampling will be done to include the smallest
1715-
absolute value; for example, if zero is included in the
1716-
array of possibilities, then it is guaranteed to be one of
1711+
Place ticks at a set of fixed values.
1712+
1713+
If *nbins* is None ticks are placed at all values. Otherwise, the *locs* array of
1714+
possible positions will be subsampled to keep the number of ticks <=
1715+
:math:`nbins* +1`. The subsampling will be done to include the smallest absolute
1716+
value; for example, if zero is included in the array of possibilities, then it of
17171717
the chosen ticks.
17181718
"""
17191719

@@ -1773,7 +1773,7 @@ def tick_values(self, vmin, vmax):
17731773

17741774
class LinearLocator(Locator):
17751775
"""
1776-
Determine the tick locations
1776+
Place ticks at evenly spaced values.
17771777
17781778
The first time this function is called it will try to set the
17791779
number of ticks to make a nice tick partitioning. Thereafter, the
@@ -1854,8 +1854,7 @@ def view_limits(self, vmin, vmax):
18541854

18551855
class MultipleLocator(Locator):
18561856
"""
1857-
Set a tick on each integer multiple of the *base* plus an *offset* within
1858-
the view interval.
1857+
Place ticks at every integer multiple of a base plus an offset.
18591858
"""
18601859

18611860
def __init__(self, base=1.0, offset=0.0):
@@ -1983,7 +1982,9 @@ def ge(self, x):
19831982

19841983
class MaxNLocator(Locator):
19851984
"""
1986-
Find nice tick locations with no more than *nbins* + 1 being within the
1985+
Place evenly spaced ticks, with a cap on the total number of ticks.
1986+
1987+
Finds nice tick locations with no more than :math:`nbins + 1` ticks being within the
19871988
view limits. Locations beyond the limits are added to support autoscaling.
19881989
"""
19891990
default_params = dict(nbins=10,
@@ -2266,38 +2267,34 @@ def _is_close_to_int(x):
22662267

22672268
class LogLocator(Locator):
22682269
"""
2270+
Place logarithmically spaced ticks.
22692271
2270-
Determine the tick locations for log axes.
2271-
2272-
Place ticks on the locations : ``subs[j] * base**i``
2273-
2274-
Parameters
2275-
----------
2276-
base : float, default: 10.0
2277-
The base of the log used, so major ticks are placed at
2278-
``base**n``, where ``n`` is an integer.
2279-
subs : None or {'auto', 'all'} or sequence of float, default: (1.0,)
2280-
Gives the multiples of integer powers of the base at which
2281-
to place ticks. The default of ``(1.0, )`` places ticks only at
2282-
integer powers of the base.
2283-
Permitted string values are ``'auto'`` and ``'all'``.
2284-
Both of these use an algorithm based on the axis view
2285-
limits to determine whether and how to put ticks between
2286-
integer powers of the base. With ``'auto'``, ticks are
2287-
placed only between integer powers; with ``'all'``, the
2288-
integer powers are included. A value of None is
2289-
equivalent to ``'auto'``.
2290-
numticks : None or int, default: None
2291-
The maximum number of ticks to allow on a given axis. The default
2292-
of ``None`` will try to choose intelligently as long as this
2293-
Locator has already been assigned to an axis using
2294-
`~.axis.Axis.get_tick_space`, but otherwise falls back to 9.
2295-
2272+
Places ticks at the values ``subs[j] * base**i``.
22962273
"""
22972274

22982275
@_api.delete_parameter("3.8", "numdecs")
22992276
def __init__(self, base=10.0, subs=(1.0,), numdecs=4, numticks=None):
2300-
"""Place ticks on the locations : subs[j] * base**i."""
2277+
"""
2278+
Parameters
2279+
----------
2280+
base : float, default: 10.0
2281+
The base of the log used, so major ticks are placed at ``base**n``, where
2282+
``n`` is an integer.
2283+
subs : None or {'auto', 'all'} or sequence of float, default: (1.0,)
2284+
Gives the multiples of integer powers of the base at which to place ticks.
2285+
The default of ``(1.0, )`` places ticks only at integer powers of the base.
2286+
Permitted string values are ``'auto'`` and ``'all'``. Both of these use an
2287+
algorithm based on the axis view limits to determine whether and how to put
2288+
ticks between integer powers of the base:
2289+
- ``'auto'``: Ticks are placed only between integer powers.
2290+
- ``'all'``: Ticks are placed between *and* at integer powers.
2291+
- ``None``: Equivalent to ``'auto'``.
2292+
numticks : None or int, default: None
2293+
The maximum number of ticks to allow on a given axis. The default of
2294+
``None`` will try to choose intelligently as long as this Locator has
2295+
already been assigned to an axis using `~.axis.Axis.get_tick_space`, but
2296+
otherwise falls back to 9.
2297+
"""
23012298
if numticks is None:
23022299
if mpl.rcParams['_internal.classic_mode']:
23032300
numticks = 15
@@ -2464,7 +2461,7 @@ def nonsingular(self, vmin, vmax):
24642461

24652462
class SymmetricalLogLocator(Locator):
24662463
"""
2467-
Determine the tick locations for symmetric log axes.
2464+
Place ticks spaced linearly near zero and spaced logarithmically beyond a threshold.
24682465
"""
24692466

24702467
def __init__(self, transform=None, subs=None, linthresh=None, base=None):
@@ -2618,10 +2615,9 @@ def view_limits(self, vmin, vmax):
26182615

26192616
class AsinhLocator(Locator):
26202617
"""
2621-
An axis tick locator specialized for the inverse-sinh scale
2618+
Place ticks spaced evenly on an inverse-sinh scale.
26222619
2623-
This is very unlikely to have any use beyond
2624-
the `~.scale.AsinhScale` class.
2620+
Generally used with the `~.scale.AsinhScale` class.
26252621
26262622
.. note::
26272623
@@ -2711,13 +2707,11 @@ def tick_values(self, vmin, vmax):
27112707

27122708
class LogitLocator(MaxNLocator):
27132709
"""
2714-
Determine the tick locations for logit axes
2710+
Place ticks spaced evenly on a logit scale.
27152711
"""
27162712

27172713
def __init__(self, minor=False, *, nbins="auto"):
27182714
"""
2719-
Place ticks on the logit locations
2720-
27212715
Parameters
27222716
----------
27232717
nbins : int or 'auto', optional
@@ -2859,9 +2853,11 @@ def nonsingular(self, vmin, vmax):
28592853

28602854
class AutoLocator(MaxNLocator):
28612855
"""
2862-
Dynamically find major tick positions. This is actually a subclass
2863-
of `~matplotlib.ticker.MaxNLocator`, with parameters *nbins = 'auto'*
2864-
and *steps = [1, 2, 2.5, 5, 10]*.
2856+
Place evenly spaced ticks, with the step size and maximum number of ticks chosen
2857+
automatically.
2858+
2859+
This is a subclass of `~matplotlib.ticker.MaxNLocator`, with parameters
2860+
*nbins = 'auto'* and *steps = [1, 2, 2.5, 5, 10]*.
28652861
"""
28662862
def __init__(self):
28672863
"""
@@ -2879,8 +2875,10 @@ def __init__(self):
28792875

28802876
class AutoMinorLocator(Locator):
28812877
"""
2882-
Dynamically find minor tick positions based on the positions of
2883-
major ticks. The scale must be linear with major ticks evenly spaced.
2878+
Place evenly spaced minor ticks, with the step size and maximum number of ticks
2879+
chosen automatically.
2880+
2881+
The Axis scale must be linear with evenly spaced major ticks .
28842882
"""
28852883

28862884
def __init__(self, n=None):

0 commit comments

Comments
 (0)