How to find a Y value based on X value in 2Dline

How to find a Y value based on X value in 2Dline

Hello, everyone,

I am creating a plot based on several (x,y) value pairs (it constitutes some fuel burn envelope).

Then I have to draw a line parallel to X axis with a given value of X that would start at my plot, which means I have to find a value of Y on my plot

that corresponds to a given X. Or an intersection of my plot and the line parallel to X axis.

I couldn’t find a way to do it.

If somebody can help I’ really appreciate it.

Thanks

I think what you are asking for is interpolation. You have a set of
(x,y) data, and you want to find a new y-value corresponding to a
given x-value.

Take a look at scipy.interpolate.interp1d

import numpy
import scipy
import scipy.interpolate
# Set up fake "data".
x= numpy.arange(10)
y = numpy.sin(x)
# Set up an interpolate object.
interp_func = scipy.interpolate.interp1d(x, y)
# Find the intepolated value of y, given x=3.5.
ynew = interp_func(3.5)
print ynew

Hope that helps,
Roban

···

On Fri, Aug 8, 2008 at 2:14 PM, Kazansky, Stella (SKAZANSK) <SKAZANSK@...2122...> wrote:

Hello, everyone,
I am creating a plot based on several (x,y) value pairs (it constitutes some
fuel burn envelope).

Then I have to draw a line parallel to X axis with a given value of X that
would start at my plot, which means I have to find a value of Y on my plot

that corresponds to a given X. Or an intersection of my plot and the line
parallel to X axis.

I couldn't find a way to do it.
If somebody can help I' really appreciate it.

Thanks

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options