How to display Matplotlib Y-axis range using absolute values rather than offset values?


To display Y-axis range using absolute values rather than offset values, we can take the following steps −

  • Create x_data and y_data data points in the range of 100 to 1000.

  • Create a figure and a set of subplots using subplots() method.

  • Plot x_data and y_data using plot() method.

  • If a parameter is not set, the corresponding property of the formatter is left unchanged using ticklabel_format() method with useOffset=False.

  • 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
x_date = range(100, 1000, 100)
y_data = range(100, 1000, 100)
fig, ax = plt.subplots()
ax.plot(x_date, y_data)
ax.ticklabel_format(useOffset=False)
plt.show()

Output

Updated on: 08-May-2021

696 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements