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

    Click :ref:`here <sphx_glr_download_gallery_pyplots_pyplot_scales.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_pyplots_pyplot_scales.py:


=============
Pyplot Scales
=============

Create plots on different scales. Here a linear, a logarithmic, a symmetric
logarithmic and a logit scale are shown. For further examples also see the
:ref:`scales_examples` section of the gallery.



.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt

    from matplotlib.ticker import NullFormatter  # useful for `logit` scale

    # Fixing random state for reproducibility
    np.random.seed(19680801)

    # make up some data in the interval ]0, 1[
    y = np.random.normal(loc=0.5, scale=0.4, size=1000)
    y = y[(y > 0) & (y < 1)]
    y.sort()
    x = np.arange(len(y))

    # plot with various axes scales
    plt.figure(1)

    # linear
    plt.subplot(221)
    plt.plot(x, y)
    plt.yscale('linear')
    plt.title('linear')
    plt.grid(True)


    # log
    plt.subplot(222)
    plt.plot(x, y)
    plt.yscale('log')
    plt.title('log')
    plt.grid(True)


    # symmetric log
    plt.subplot(223)
    plt.plot(x, y - y.mean())
    plt.yscale('symlog', linthreshy=0.01)
    plt.title('symlog')
    plt.grid(True)

    # logit
    plt.subplot(224)
    plt.plot(x, y)
    plt.yscale('logit')
    plt.title('logit')
    plt.grid(True)
    # Format the minor tick labels of the y-axis into empty strings with
    # `NullFormatter`, to avoid cumbering the axis with too many labels.
    plt.gca().yaxis.set_minor_formatter(NullFormatter())
    # Adjust the subplot layout, because the logit one may take more space
    # than usual, due to y-tick labels like "1 - 10^{-3}"
    plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25,
                        wspace=0.35)

    plt.show()




.. image:: /gallery/pyplots/images/sphx_glr_pyplot_scales_001.png
    :class: sphx-glr-single-img




------------

References
""""""""""

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



.. code-block:: python


    import matplotlib
    matplotlib.pyplot.subplot
    matplotlib.pyplot.subplots_adjust
    matplotlib.pyplot.gca
    matplotlib.pyplot.yscale
    matplotlib.ticker.NullFormatter
    matplotlib.axis.Axis.set_minor_formatter







.. _sphx_glr_download_gallery_pyplots_pyplot_scales.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
