Home > Backend Development > Python Tutorial > How to Prevent Scientific Notation and Axis Offsets in Matplotlib Plots?

How to Prevent Scientific Notation and Axis Offsets in Matplotlib Plots?

Barbara Streisand
Release: 2024-12-27 10:53:10
Original
334 people have browsed it

How to Prevent Scientific Notation and Axis Offsets in Matplotlib Plots?

Prevent Scientific Notation in Matplotlib Plots

In matplotlib plots, scientific notation and axis offsets are two distinct features. Here's how to control them separately:

Disable Scientific Notation

To disable scientific notation (multiplier), use ax.ticklabel_format(style='plain') or plt.ticklabel_format(style='plain').

fig, ax = plt.subplots()
ax.plot(range(2003, 2012, 1), range(200300, 201200, 100))
ax.ticklabel_format(style='plain')
plt.show()
Copy after login

Disable Axis Offset

To disable axis offset (addition), use ax.ticklabel_format(useOffset=False) or plt.ticklabel_format(useOffset=False).

fig, ax = plt.subplots()
ax.plot(range(2003, 2012, 1), range(200300, 201200, 100))
ax.ticklabel_format(useOffset=False)
plt.show()
Copy after login

Disable Both Scientific Notation and Axis Offset

To disable both simultaneously, use ax.ticklabel_format(useOffset=False,> or plt.ticklabel_format(useOffset=False,>.

fig, ax = plt.subplots()
ax.plot(range(2003, 2012, 1), range(200300, 201200, 100))
ax.ticklabel_format(useOffset=False,>
Copy after login

The above is the detailed content of How to Prevent Scientific Notation and Axis Offsets in Matplotlib Plots?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template