

.. _sphx_glr_gallery_api_engineering_formatter.py:


=========================================
Labeling ticks using engineering notation
=========================================

Demo to show use of the engineering Formatter.




.. image:: /gallery/api/images/sphx_glr_engineering_formatter_001.png
    :align: center





.. code-block:: python


    import matplotlib.pyplot as plt
    import numpy as np

    from matplotlib.ticker import EngFormatter

    # Fixing random state for reproducibility
    prng = np.random.RandomState(19680801)

    fig, ax = plt.subplots()
    ax.set_xscale('log')
    formatter = EngFormatter(unit='Hz')
    ax.xaxis.set_major_formatter(formatter)

    xs = np.logspace(1, 9, 100)
    ys = (0.8 + 0.4 * prng.uniform(size=100)) * np.log10(xs)**2
    ax.plot(xs, ys)

    plt.show()

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



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
