Skip to content

Commit bb6c71c

Browse files
committed
Clarify that explicit ticklabels are used without further formatting.
This was not made explicit in the docs (it is in essence due to the use of FixedFormatter, but that's a rather involved detail for end users). Also minor rewordings.
1 parent e3a5cee commit bb6c71c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/matplotlib/axis.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ def set_ticklabels(self, labels, *, minor=False, fontdict=None, **kwargs):
19621962
labels : sequence of str or of `.Text`\s
19631963
Texts for labeling each tick location in the sequence set by
19641964
`.Axis.set_ticks`; the number of labels must match the number of
1965-
locations.
1965+
locations. The labels are used as is, without further formatting.
19661966
19671967
minor : bool
19681968
If True, set minor ticks instead of major ticks.
@@ -2093,26 +2093,25 @@ def set_ticks(self, ticks, labels=None, *, minor=False, **kwargs):
20932093
Parameters
20942094
----------
20952095
ticks : 1D array-like
2096-
Array of tick locations. The axis `.Locator` is replaced by a
2097-
`~.ticker.FixedLocator`.
2096+
Array of tick locations (either floats or in axis units). The axis
2097+
`.Locator` is replaced by a `~.ticker.FixedLocator`.
20982098
2099-
The values may be either floats or in axis units.
2100-
2101-
Pass an empty list to remove all ticks::
2102-
2103-
set_ticks([])
2099+
Pass an empty list (``set_ticks([])``) to remove all ticks.
21042100
21052101
Some tick formatters will not label arbitrary tick positions;
21062102
e.g. log formatters only label decade ticks by default. In
21072103
such a case you can set a formatter explicitly on the axis
21082104
using `.Axis.set_major_formatter` or provide formatted
21092105
*labels* yourself.
2106+
21102107
labels : list of str, optional
2111-
Tick labels for each location in *ticks*. *labels* must be of the same
2112-
length as *ticks*. If not set, the labels are generate using the axis
2113-
tick `.Formatter`.
2108+
Tick labels for each location in *ticks*; must have the same length as
2109+
*ticks*. If set, the labels are used as is, via a `.FixedFormatter`.
2110+
If not set, the labels are generated using the axis tick `.Formatter`.
2111+
21142112
minor : bool, default: False
21152113
If ``False``, set the major ticks; if ``True``, the minor ticks.
2114+
21162115
**kwargs
21172116
`.Text` properties for the labels. Using these is only allowed if
21182117
you pass *labels*. In other cases, please use `~.Axes.tick_params`.

0 commit comments

Comments
 (0)