Home >Backend Development >Python Tutorial >How to Remove Scientific Notation and Offsets from Matplotlib Plots?
You have a plot with scientific notation and an offset on the axes, and you want to eliminate them.
The offset is separate from scientific notation and is added to the numbers displayed on the axis. To disable it, use:
plt.ticklabel_format(useOffset=False)
To prevent scientific notation, use:
plt.ticklabel_format(style='plain')
To disable both the offset and scientific notation, use:
plt.ticklabel_format(useOffset=False,>
Suppose you have the following code:
import matplotlib.pyplot as plt plt.plot(range(2003, 2012, 1), range(200300, 201200, 100)) plt.ticklabel_format(useOffset=False) plt.show()
Which produces this plot:
[Image of plot]
By applying the correct settings, you can eliminate both the offset and scientific notation:
import matplotlib.pyplot as plt plt.plot(range(2003, 2012, 1), range(200300, 201200, 100)) plt.ticklabel_format(useOffset=False,>
Resulting in this plot:
[Image of plot without scientific notation and offset]
The above is the detailed content of How to Remove Scientific Notation and Offsets from Matplotlib Plots?. For more information, please follow other related articles on the PHP Chinese website!