i want to get equation or value on matplotlib plot
i make plot x: range(5), y = [ 5, 20, 1, 7,9 ]
matplotlib make plot like under the picture.
And then, i want to get value that is between 20 and 1
I guess matplotlib fit anything model, and make y_hat and plotting y_hats
so, who are teach me, how to get eqation or access equation or value
-- if you don't understand my text, reference the picture. i think, you will understand what i want to do.
It will be very easy to use the NumPy interp function. Just giving the x-positions and original X,Y array. np.interp will return the corresponding y-values (Linear interpolation).
import numpy as np
import matplotlib.pyplot as plt
x = range(5)
y = [ 5 , 20 , 1 , 7 ,9 ]
xvals = np.linspace(1, 2, 10)
yinterp = np.interp(xvals, x, y)
plt.plot(x, y, '-o',label="org data")
plt.plot(xvals, yinterp, 'x',label="interp data")
plt.legend()
plt.savefig("interp.png")
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.