- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove relative shift in Matplotlib axis?
To remove relative shift in matplotlib axis, we can take the following steps −
Plot a line with two input lists.
Using gca() method, get the current axis and then return the X-axis instance. Get the formatter of the major ticker. To remove the relative shift, use set_useOffset(False) method.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True plt.plot([10, 101, 1001], [1, 2, 3]) plt.gca().get_xaxis().get_major_formatter().set_useOffset(False) plt.show()
Output
- Related Articles
- How to shift a graph along the X-axis in matplotlib?
- How to remove the digits after the decimal point in axis ticks in Matplotlib?
- How to shift the colorbar position to right in matplotlib?
- How to remove or hide X-axis labels from a Seaborn / Matplotlib plot?
- How to enforce axis range in Matplotlib?
- How to remove the first and last ticks label of each Y-axis subplot in Matplotlib?
- Remove the X-axis ticks while keeping the grids (Matplotlib)
- How to customize the X-axis in Matplotlib?
- How to customize X-axis ticks in Matplotlib?
- How to access axis label object in Matplotlib?
- How to remove Y-axis labels in R?
- How to replace auto-labelled relative values by absolute values in Matplotlib?
- How to add a second X-axis in Matplotlib?
- How to set X-axis values in Matplotlib Python?
- How to remove lines in a Matplotlib plot?

Advertisements