1
import matplotlib.pyplot as plt
from numpy import polyfit
Defining known X and Y
X = [0, 5]
Y = [2, 4]
By calculating the coefficients
m, b = polyfit(X, Y, deg=1)
New x for calculation
x = 2.5
Line equation y = mx + b
y = m * x + b
Plotting
plt.plot(X,Y)
plt.plot(x, y, 'go')
plt.show()
It seems like a mathematical question. Little code, could you share more? Logically you should work with an array.
– Rogers Corrêa