How to set axis to start from corner in Matplotlib

Viewed 11589

this is a graph that I plotted:

# MatPlotlib
import matplotlib.pyplot as plt
# Scientific libraries
import numpy as np

plt.figure(1)

points = np.array([(100, 6.09),
                   (111, 8.42),
                   (119, 10.6),
                   (129, 12.5),
                   (139, 14.9),
                   (149, 17.2),
                   (200, 28.9),
                   (250, 40.9),
                   (299, 52.4),
                   (349, 64.7),
                   (400, 76.9)])

# get x and y vectors
x = points[:,0]
y = points[:,1]
# calculate polynomial
z = np.polyfit(x, y, 3)
f = np.poly1d(z)
# calculate new x's and y's
x_new = np.linspace(x[0], x[-1], 50)
y_new = f(x_new)

plt.plot(x,y,'bo', x_new, y_new)

plt.show()

enter image description here

I find that all the graphs I plot do not have their axes starting from the corner of the box, could anyone tell me how I can correct this? Aside from setting limits in the graph

1 Answers
Related