Home > Backend Development > Python Tutorial > How to Remove Scientific Notation and Offsets from Matplotlib Plots?

How to Remove Scientific Notation and Offsets from Matplotlib Plots?

Susan Sarandon
Release: 2024-12-11 18:23:11
Original
306 people have browsed it

How to Remove Scientific Notation and Offsets from Matplotlib Plots?

Removing Scientific Notation from Matplotlib Plots

You have a plot with scientific notation and an offset on the axes, and you want to eliminate them.

Disabling the Offset

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)
Copy after login

Disabling Scientific Notation

To prevent scientific notation, use:

plt.ticklabel_format(style='plain')
Copy after login

Disabling Both

To disable both the offset and scientific notation, use:

plt.ticklabel_format(useOffset=False,>
Copy after login

Example

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()
Copy after login

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,>
Copy after login

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!

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