对于下面的代码,我如何制作具有指定距离的平行线。
给出第一个线点A(0,7)B(5,2)
第二行(3,2)
import matplotlib.pyplot as plt
import math
import numpy as np
x=[0, 7]
y=[5, 2]
plt.plot(x,y)
o = np.subtract(2, 7)
q = np.subtract(5, 0)
slope = o/q
#(m,p) are the new coordinates to plot the parallel line
m = 3
p = 2
axes = plt.gca()
x_val = np.array(axes.get_xlim())
y_val = np.array(slope*(x_val - m) + p)
plt.plot(x_val,y_val, color="black", linestyle="--")
plt.show()