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

DOC: scales - built in options and custom scale usefulness #29404

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
merged 1 commit into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
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
24 changes: 18 additions & 6 deletions 24 galleries/examples/scales/custom_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
Custom scale
============

Create a custom scale, by implementing the scaling use for latitude data in a
Mercator Projection.
Custom scales can be created in two ways

#. For simple cases, use `~.scale.FuncScale` and the ``'function'`` option of
`~.Axes.set_xscale` and `~.Axes.set_yscale`. See the last example in
:doc:`/gallery/scales/scales`.

#. Create a custom scale class such as the one in this example, which implements
the scaling use for latitude data in a Mercator Projection. This more complicated
approach is useful when

* You are making special use of the `.Transform` class, such as the special
handling of values beyond the threshold in ``MercatorLatitudeTransform``
below.

* You want to override the default locators and formatters for the axis
(``set_default_locators_and_formatters`` below).

* You want to limit the range of the the axis (``limit_range_for_scale`` below).

Unless you are making special use of the `.Transform` class, you probably
don't need to use this verbose method, and instead can use `~.scale.FuncScale`
and the ``'function'`` option of `~.Axes.set_xscale` and `~.Axes.set_yscale`.
See the last example in :doc:`/gallery/scales/scales`.
"""

import numpy as np
Expand Down
25 changes: 7 additions & 18 deletions 25 lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,26 +760,15 @@ def _set_axes_scale(self, value, **kwargs):

Parameters
----------
value : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
The axis scale type to apply.
value : str or `.ScaleBase`
The axis scale type to apply. Valid string values are the names of scale
classes ("linear", "log", "function",...). These may be the names of any
of the :ref:`built-in scales<builtin_scales>` or of any custom scales
registered using `matplotlib.scale.register_scale`.

**kwargs
Different keyword arguments are accepted, depending on the scale.
See the respective class keyword arguments:

- `matplotlib.scale.LinearScale`
- `matplotlib.scale.LogScale`
- `matplotlib.scale.SymmetricalLogScale`
- `matplotlib.scale.LogitScale`
- `matplotlib.scale.FuncScale`
- `matplotlib.scale.AsinhScale`

Notes
-----
By default, Matplotlib supports the above-mentioned scales.
Additionally, custom scales may be registered using
`matplotlib.scale.register_scale`. These scales can then also
be used here.
If *value* is a string, keywords are passed to the instantiation method of
the respective class.
"""
name = self._get_axis_name()
old_default_lims = (self.get_major_locator()
Expand Down
4 changes: 3 additions & 1 deletion 4 lib/matplotlib/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

The mapping is implemented through `.Transform` subclasses.

The following scales are builtin:
The following scales are built-in:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merriam-Webster says this is hyphenated, though we seem to have both ways all over the docs...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatGPT says:

The correct spelling depends on how the term is used in a sentence:

  1. "Built-in" (with a hyphen) is an adjective. It is used to describe something that is an integral or permanent part of something else.

    • Example: "The phone has a built-in camera."
  2. "Builtin" (no hyphen) is not a standard English word, but it is sometimes used as a term in programming or technical contexts, especially in filenames, identifiers, or codebases. For instance, Python has "builtin functions," though even here, "built-in" is more widely accepted in official documentation.

To summarize:

  • For general usage, "built-in" with a hyphen is correct.
  • For programming or technical contexts, check the convention of the specific language or framework being used.


.. _builtin_scales:

============= ===================== ================================ =================================
Name Class Transform Inverted transform
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.