Skip to content

Commit 278cc4c

Browse files
committed
DOC: scales - built in options and custom scale usefulness
1 parent 710cee1 commit 278cc4c

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

galleries/examples/scales/custom_scale.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
Custom scale
66
============
77
8-
Create a custom scale, by implementing the scaling use for latitude data in a
9-
Mercator Projection.
8+
Custom scales can be created in two ways
9+
10+
#. For simple cases, use `~.scale.FuncScale` and the ``'function'`` option of
11+
`~.Axes.set_xscale` and `~.Axes.set_yscale`. See the last example in
12+
:doc:`/gallery/scales/scales`.
13+
14+
#. Create a custom scale class such as the one in this example, which implements
15+
the scaling use for latitude data in a Mercator Projection. This more complicated
16+
approach is useful when
17+
18+
* You are making special use of the `.Transform` class, such as the special
19+
handling of values beyond the threshold in ``MercatorLatitudeTransform``
20+
below.
21+
22+
* You want to override the default locators and formatters for the axis
23+
(``set_default_locators_and_formatters`` below).
24+
25+
* You want to limit the range of the the axis (``limit_range_for_scale`` below).
1026
11-
Unless you are making special use of the `.Transform` class, you probably
12-
don't need to use this verbose method, and instead can use `~.scale.FuncScale`
13-
and the ``'function'`` option of `~.Axes.set_xscale` and `~.Axes.set_yscale`.
14-
See the last example in :doc:`/gallery/scales/scales`.
1527
"""
1628

1729
import numpy as np

lib/matplotlib/axis.py

+7-18
Original file line numberDiff line numberDiff line change
@@ -760,26 +760,15 @@ def _set_axes_scale(self, value, **kwargs):
760760
761761
Parameters
762762
----------
763-
value : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
764-
The axis scale type to apply.
763+
value : str or `.ScaleBase`
764+
The axis scale type to apply. Valid string values are the names of scale
765+
classes ("linear", "log", "function",...). These may be the names of any
766+
of the :ref:`built-in scales<builtin_scales>` or of any custom scales
767+
registered using `matplotlib.scale.register_scale`.
765768
766769
**kwargs
767-
Different keyword arguments are accepted, depending on the scale.
768-
See the respective class keyword arguments:
769-
770-
- `matplotlib.scale.LinearScale`
771-
- `matplotlib.scale.LogScale`
772-
- `matplotlib.scale.SymmetricalLogScale`
773-
- `matplotlib.scale.LogitScale`
774-
- `matplotlib.scale.FuncScale`
775-
- `matplotlib.scale.AsinhScale`
776-
777-
Notes
778-
-----
779-
By default, Matplotlib supports the above-mentioned scales.
780-
Additionally, custom scales may be registered using
781-
`matplotlib.scale.register_scale`. These scales can then also
782-
be used here.
770+
If *value* is a string, keywords are passed to the instantiation method of
771+
the respective class.
783772
"""
784773
name = self._get_axis_name()
785774
old_default_lims = (self.get_major_locator()

lib/matplotlib/scale.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
44
The mapping is implemented through `.Transform` subclasses.
55
6-
The following scales are builtin:
6+
The following scales are built-in:
7+
8+
.. _builtin_scales:
79
810
============= ===================== ================================ =================================
911
Name Class Transform Inverted transform

0 commit comments

Comments
 (0)