[英]How can I automate code to plot a line between two points?
Currently trying to create an automated function that can find a line between two points.目前正在尝试创建一个自动化的 function,它可以找到两点之间的一条线。 Tried testing this function (by plotting) but when I plot the function I get a 'v-shaped' line.
尝试测试此 function(通过绘图)但是当我 plot function 我得到一条“v 形”线。 What changes can I make to complete this function?
我可以进行哪些更改来完成此 function? Thanks.
谢谢。
import matplotlib.pyplot as plt
from math import e
x = [0, 9]
y = [7, 2]
m = (y[1]-x[1])/(y[0]-x[0])
b = m*(y[0]-x[0])+x[1]
for i in range (-10, 10):
prob_x = m*i + b
x.append(i)
y.append(prob_x)
plt.plot(x,y)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.