def drawLine2P(x, y, xlims):
    xrange = np.arange(xlims[0], xlims[1], 0.1)
A = np.vstack([x, np.ones(len(x))]).T
k, b = np.linalg.lstsq(A, y)[0]
plt.plot(xrange, k * xrange + b, 'k')
matplotlib: extended line over 2 control points