How to Set Tick Label in Scientific Notation in Matplotlib

Shiv Yadav Feb 02, 2024
How to Set Tick Label in Scientific Notation in Matplotlib

This post will teach you about using Matplotlib ticklabel_format() to display ticks label in scientific notation.

Matplotlib Tick Label in Scientific Notation

Too large or too few numbers readily stated in decimal form can be expressed using scientific notation.

First, import the necessary library:

import matplotlib.pyplot as plt

Provide the values along with the x and y axes:

x_val = [1000000, 2000000, 3000000]
y_val = [1, 2, 3]

Let’s plot these numbers using Matplotlib:

plt.plot(x_val, y_val)

plt.ticklabel_format(axis="x", style="sci", scilimits=(0, 0))


Plot Using Matplotlib

To plot, we use the ticklabel_format() function, which takes the parameter axes and style=sci, which denotes the scientific notation.

Author: Shiv Yadav
Shiv Yadav avatar Shiv Yadav avatar

Shiv is a self-driven and passionate Machine learning Learner who is innovative in application design, development, testing, and deployment and provides program requirements into sustainable advanced technical solutions through JavaScript, Python, and other programs for continuous improvement of AI technologies.


Related Article - Matplotlib Ticks

Related Article - Matplotlib Axes