0
x = numpy.arange(0.0, 5, 1)
y = numpy.array([np.nan,2,3,4,5])
plt.plot(x,y)

I am trying to plot, but the graph always starts with 1 instead of 0. Can I force it to start with 0 ?

infoclogged
  • 3,641
  • 5
  • 32
  • 53
  • 1
    Possible duplicate of [Set axis limits in matplotlib graph](https://stackoverflow.com/questions/23268277/set-axis-limits-in-matplotlib-graph) – Jeremy McGibbon Apr 26 '18 at 21:02

1 Answers1

0

Use the following to set the minimum x value to 0:

import numpy
import matplotlib.pyplot as plt

x = numpy.arange(0.0, 5, 1)
y = numpy.array([numpy.nan, 2, 3, 4, 5])
plt.plot(x, y)
plt.xlim(xmin=0)
plt.show()

You can do the same for the y-axis by using ylim:

plt.ylim(ymin=0)
Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51