Reputation: 69
I have two arrays x
, y
with coordinates of a function.
Example:
x=[0,1,2,3,4,5]
y=[0,1,5,20,30,32]
pylab.plot(x,y)
shows me a smooth function for this.
Is there a way to get the x
-Value for y=3
?
regards
Upvotes: 1
Views: 338
Reputation: 310097
You should be able to use numpy.interp
for this.
e.g.:
numpy.interp(3.,y,x) #1.5
Note that this only works since your y values are monotonic. If your y-values aren't monotonic, there is no guarantee that your mapping of y->x is unique.
Upvotes: 3