You are reading an old version of the documentation (v1.4.3). For the latest version see https://matplotlib.org/stable/

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates

matplotlib

Previous topic

api example code: donut_demo.py

Next topic

api example code: font_family_rc.py

This Page

api example code: engineering_formatter.pyΒΆ

(Source code, png, hires.png, pdf)

../../_images/engineering_formatter.png
'''
Demo to show use of the engineering Formatter.
'''

import matplotlib.pyplot as plt
import numpy as np

from matplotlib.ticker import EngFormatter

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

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

plt.show()

Keywords: python, matplotlib, pylab, example, codex (see Search examples)