Matplotlib Tick Label in Scientific Notation

Matplotlib Tick Label in Scientific Notation

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))

Output:

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.

LinkedIn

Related Article - Matplotlib Ticks

  • Rotate X-Axis Tick Label Text in Matplotlib
  • Set Tick Labels Font Size in Matplotlib
  • Hide Axis Text Ticks and/or Tick Labels in Matplotlib
  • Set Number of Ticks in Matplotlib
  • Related Article - Matplotlib Axes

  • Rotate X-Axis Tick Label Text in Matplotlib
  • Set Tick Labels Font Size in Matplotlib
  • Add a Y-Axis Label to the Secondary Y-Axis in Matplotlib
  • Plot Logarithmic Axes in Matplotlib
  • Make a Square Plot With Equal Axes in Matplotlib
  • Set Limits for Axes in Matplotlib