You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1772+gd9240e24b
Fork me on GitHub

Table Of Contents

Related Topics

Dollar Ticks

Use a 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

fig, ax = plt.subplots()

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

for tick in ax.yaxis.get_major_ticks():
    tick.label1On = False
    tick.label2On = True


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

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery