
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/ticks/scalarformatter.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_ticks_scalarformatter.py>`
        to download the full example code.

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

.. _sphx_glr_gallery_ticks_scalarformatter.py:


==========================
The default tick formatter
==========================

By default, tick labels are formatted using a `.ScalarFormatter`, which can be
configured via `~.axes.Axes.ticklabel_format`.  This example illustrates some
possible configurations:

- Default.
- ``useMathText=True``: Fancy formatting of mathematical expressions.
- ``useOffset=False``: Do not use offset notation; see
  `.ScalarFormatter.set_useOffset`.

.. GENERATED FROM PYTHON SOURCE LINES 15-39



.. image-sg:: /gallery/ticks/images/sphx_glr_scalarformatter_001.png
   :alt: default settings, useMathText=True, useOffset=False
   :srcset: /gallery/ticks/images/sphx_glr_scalarformatter_001.png, /gallery/ticks/images/sphx_glr_scalarformatter_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    x = np.arange(0, 1, .01)
    fig, axs = plt.subplots(
        3, 3, figsize=(9, 9), layout="constrained", gridspec_kw={"hspace": 0.1})

    for col in axs.T:
        col[0].plot(x * 1e5 + 1e10, x * 1e-10 + 1e-5)
        col[1].plot(x * 1e5, x * 1e-4)
        col[2].plot(-x * 1e5 - 1e10, -x * 1e-5 - 1e-10)

    for ax in axs[:, 1]:
        ax.ticklabel_format(useMathText=True)
    for ax in axs[:, 2]:
        ax.ticklabel_format(useOffset=False)

    plt.rcParams.update({"axes.titleweight": "bold", "axes.titley": 1.1})
    axs[0, 0].set_title("default settings")
    axs[0, 1].set_title("useMathText=True")
    axs[0, 2].set_title("useOffset=False")

    plt.show()


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

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


.. _sphx_glr_download_gallery_ticks_scalarformatter.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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