def slope_from_points(point1, point2):
    return (point2[1] - point1[1]) / (point2[0] - point1[0])

def plot_secant(point1, point2, ax):
    slope = slope_from_points(point1, point2)
intercept = point1[1] - slope * point1[0]
x = ax.get_xlim()
y = ax.get_ylim()
data_y = [x[0] * slope + intercept, x[1] * slope + intercept]
line = mpl_lines.Line2D(x, data_y, color='red')
ax.add_line(line)
return ax.figure()
matplotlib: расширенная линия через 2 контрольные точки