Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff2d3fe

Browse filesBrowse files
authored
Merge pull request #29462 from meeseeksmachine/auto-backport-of-pr-29404-on-v3.10.x
Backport PR #29404 on branch v3.10.x (DOC: scales - built in options and custom scale usefulness)
2 parents 8d6ec23 + bed8281 commit ff2d3fe
Copy full SHA for ff2d3fe

File tree

3 files changed

+28
-25
lines changed
Filter options

3 files changed

+28
-25
lines changed

‎galleries/examples/scales/custom_scale.py

Copy file name to clipboardExpand all lines: galleries/examples/scales/custom_scale.py
+18-6Lines changed: 18 additions & 6 deletions
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

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+7-18Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -777,26 +777,15 @@ def _set_axes_scale(self, value, **kwargs):
777777
778778
Parameters
779779
----------
780-
value : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
781-
The axis scale type to apply.
780+
value : str or `.ScaleBase`
781+
The axis scale type to apply. Valid string values are the names of scale
782+
classes ("linear", "log", "function",...). These may be the names of any
783+
of the :ref:`built-in scales<builtin_scales>` or of any custom scales
784+
registered using `matplotlib.scale.register_scale`.
782785
783786
**kwargs
784-
Different keyword arguments are accepted, depending on the scale.
785-
See the respective class keyword arguments:
786-
787-
- `matplotlib.scale.LinearScale`
788-
- `matplotlib.scale.LogScale`
789-
- `matplotlib.scale.SymmetricalLogScale`
790-
- `matplotlib.scale.LogitScale`
791-
- `matplotlib.scale.FuncScale`
792-
- `matplotlib.scale.AsinhScale`
793-
794-
Notes
795-
-----
796-
By default, Matplotlib supports the above-mentioned scales.
797-
Additionally, custom scales may be registered using
798-
`matplotlib.scale.register_scale`. These scales can then also
799-
be used here.
787+
If *value* is a string, keywords are passed to the instantiation method of
788+
the respective class.
800789
"""
801790
name = self._get_axis_name()
802791
old_default_lims = (self.get_major_locator()

‎lib/matplotlib/scale.py

Copy file name to clipboardExpand all lines: lib/matplotlib/scale.py
+3-1Lines changed: 3 additions & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.