| [ Web Proxy ] |
| Viewing: https://matplotlib.org/stable/api/_as_gen/../../gallery/ticks/engformatter_offset.html | [Back] [Original] |
Section Navigation
fill_between with transparencyhisttype settingsplt.subplotsfloating_axes featuresNote
Go to the end to download the full example code.
matplotlib.ticker.EngFormatter is capable of computing a natural
offset for your axis data, and presenting it with a standard SI prefix
automatically calculated.
Below is an examples of such a plot:
[engformatter offset]import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker as mticker
# Fixing random state for reproducibility
np.random.seed(19680801)
UNIT = "Hz"
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(mticker.EngFormatter(
useOffset=True,
unit=UNIT
))
size = 100
measurement = np.full(size, 1e9)
noise = np.random.uniform(low=-2e3, high=2e3, size=size)
ax.plot(measurement + noise)
plt.show()
Copyright 20022012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 20122026 The Matplotlib development team.
Created using Sphinx 9.1.0.
Built from v3.11.2-1-g879ad8ebba.
Built with the PyData Sphinx Theme 0.16.1.
| Web Proxy Viewer | New URL | Original Page |