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

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

.. _sphx_glr_gallery_pyplots_dollar_ticks.py:


============
Dollar Ticks
============





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





.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.ticker as ticker

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

    fig, ax = plt.subplots()
    ax.plot(100*np.random.rand(20))

    formatter = ticker.FormatStrFormatter('$%1.2f')
    ax.yaxis.set_major_formatter(formatter)

    for tick in ax.yaxis.get_major_ticks():
        tick.label1On = False
        tick.label2On = True
        tick.label2.set_color('green')

    plt.show()


.. _sphx_glr_download_gallery_pyplots_dollar_ticks.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: dollar_ticks.ipynb <dollar_ticks.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>`_
