In [36]:
%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

# the input points
x = (10, 4)
y = (15, 20)

# reconstruct the line
# TODO take care when x[1] = x[0]
m = (y[1] - y[0]) / float((x[1] - x[0]))
b = y[1] - m * x[1]

# interpolate
xx = np.arange(x[1], x[0], 0.1)
yy = [ m * i + b for i in xx]

# plot
plt.scatter(xx, yy, color="red")
plt.scatter(x, y)


Out[36]:
<matplotlib.collections.PathCollection at 0x10bc2bc10>

In [33]:
m


Out[33]:
-1

In [ ]: