1

I have plot where the x-axis starts from 0-100. I want to change it to 10-100. I would be grateful if someone could give any suggestion.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
deepayan das
  • 1,567
  • 3
  • 14
  • 21

2 Answers2

3

If you just use pyplot for a simple plot, you can try this function:

import matplotlib.pyplot as plt
...
plt.xlim(10, 100)

If you want to set specific axes, you can try this method:

import matplotlib.pyplot as plt
...
ax = plt.gca()
ax.set_xlim(10, 100)
Y. Luo
  • 5,622
  • 1
  • 18
  • 25
3

From a SO community wiki here

set_xlim() limits the data that is displayed on the plot.

In order to change the bounds of the axis, use set_xbound()

So I'm pretty sure you actually want

ax.set_xbound(lower=10, upper=100)
Max Power
  • 8,265
  • 13
  • 50
  • 91