
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/scales/scales.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_scales_scales.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_scales_scales.py:


===============
Scales overview
===============

Illustrate the scale transformations applied to axes, e.g. log, symlog, logit.

See `matplotlib.scale` for a full list of built-in scales, and
:doc:`/gallery/scales/custom_scale` for how to create your own scale.

.. GENERATED FROM PYTHON SOURCE LINES 11-63

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    x = np.arange(400)
    y = np.linspace(0.002, 1, 400)

    fig, axs = plt.subplots(3, 2, figsize=(6, 8), layout='constrained')

    axs[0, 0].plot(x, y)
    axs[0, 0].set_yscale('linear')
    axs[0, 0].set_title('linear')
    axs[0, 0].grid(True)

    axs[0, 1].plot(x, y)
    axs[0, 1].set_yscale('log')
    axs[0, 1].set_title('log')
    axs[0, 1].grid(True)

    axs[1, 0].plot(x, y - y.mean())
    axs[1, 0].set_yscale('symlog', linthresh=0.02)
    axs[1, 0].set_title('symlog')
    axs[1, 0].grid(True)

    axs[1, 1].plot(x, y)
    axs[1, 1].set_yscale('logit')
    axs[1, 1].set_title('logit')
    axs[1, 1].grid(True)

    axs[2, 0].plot(x, y - y.mean())
    axs[2, 0].set_yscale('asinh', linear_width=0.01)
    axs[2, 0].set_title('asinh')
    axs[2, 0].grid(True)


    # Function x**(1/2)
    def forward(x):
        return x**(1/2)


    def inverse(x):
        return x**2


    axs[2, 1].plot(x, y)
    axs[2, 1].set_yscale('function', functions=(forward, inverse))
    axs[2, 1].set_title('function: $x^{1/2}$')
    axs[2, 1].grid(True)
    axs[2, 1].set_yticks(np.arange(0, 1.2, 0.2))

    plt.show()




.. image-sg:: /gallery/scales/images/sphx_glr_scales_001.png
   :alt: linear, log, symlog, logit, asinh, function: $x^{1/2}$
   :srcset: /gallery/scales/images/sphx_glr_scales_001.png, /gallery/scales/images/sphx_glr_scales_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 64-76

.. admonition:: References

   The use of the following functions, methods, classes and modules is shown
   in this example:

   - `matplotlib.axes.Axes.set_xscale`
   - `matplotlib.axes.Axes.set_yscale`
   - `matplotlib.scale.LinearScale`
   - `matplotlib.scale.LogScale`
   - `matplotlib.scale.SymmetricalLogScale`
   - `matplotlib.scale.LogitScale`
   - `matplotlib.scale.FuncScale`


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.162 seconds)


.. _sphx_glr_download_gallery_scales_scales.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: scales.ipynb <scales.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: scales.py <scales.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: scales.zip <scales.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
