You are reading an old version of the documentation (v2.1.0). For the latest version see https://matplotlib.org/stable/gallery/pyplots/dollar_ticks.html
matplotlib
Fork me on GitHub


Travis-CI:

Related Topics

This Page

Dollar TicksΒΆ

../../_images/sphx_glr_dollar_ticks_001.png
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

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

fig = plt.figure()
ax = fig.add_subplot(111)
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()

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

Gallery generated by Sphinx-Gallery