"""
============
Dollar Ticks
============

Use a `~.ticker.FormatStrFormatter` to prepend dollar signs on y axis labels.
"""
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.label1.set_visible(False)
    tick.label2.set_visible(True)
    tick.label2.set_color('green')

plt.show()

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

import matplotlib
matplotlib.ticker
matplotlib.ticker.FormatStrFormatter
matplotlib.axis.Axis.set_major_formatter
matplotlib.axis.Axis.get_major_ticks
matplotlib.axis.Tick

[((13, 0, 13, 24), 'numpy.random.seed', 'np.random.seed', ({(13, 15, 13, 23): '(19680801)'}, {}), '(19680801)', True, 'import numpy as np\n'), ((15, 10, 15, 24), 'matplotlib.pyplot.subplots', 'plt.subplots', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((18, 12, 18, 47), 'matplotlib.ticker.FormatStrFormatter', 'ticker.FormatStrFormatter', ({(18, 38, 18, 46): '"""$%1.2f"""'}, {}), "('$%1.2f')", True, 'import matplotlib.ticker as ticker\n'), ((26, 0, 26, 10), 'matplotlib.pyplot.show', 'plt.show', ({}, {}), '()', True, 'import matplotlib.pyplot as plt\n'), ((16, 12, 16, 30), 'numpy.random.rand', 'np.random.rand', ({(16, 27, 16, 29): '(20)'}, {}), '(20)', True, 'import numpy as np\n')]