Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #648 > unrolled thread

How to extract point data.

Started byNaren <a.narendiran@gmail.com>
First post2011-10-19 10:12 -0700
Last post2011-10-27 00:46 -0700
Articles 9 — 7 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  How to extract point data. Naren <a.narendiran@gmail.com> - 2011-10-19 10:12 -0700
    Re: How to extract point data. Oliver Jennrich <oliver.jennrich@gmx.net> - 2011-10-19 23:38 +0200
      Re: How to extract point data. Naren <a.narendiran@gmail.com> - 2011-10-20 00:05 -0700
        Re: How to extract point data. Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-10-21 22:54 +0200
    Re: How to extract point data. sfeam <sfeam@users.sourceforge.net> - 2011-10-19 14:42 -0700
      Re: How to extract point data. Naren <a.narendiran@gmail.com> - 2011-10-20 00:08 -0700
        Re: How to extract point data. James Cloos <cloos@jhcloos.com> - 2011-10-20 19:34 -0400
        Re: How to extract point data. Ingo Thies <ingo.thies@gmx.de> - 2011-10-21 09:02 +0200
    Re: How to extract point data. ab <ab.3942@googlemail.com> - 2011-10-27 00:46 -0700

#648 — How to extract point data.

FromNaren <a.narendiran@gmail.com>
Date2011-10-19 10:12 -0700
SubjectHow to extract point data.
Message-ID<31706069.122.1319044340309.JavaMail.geo-discussion-forums@yqoo7>
I have a data file containg values of X and Y data.

Example (Y = 2X)

X	Y

1	1
2	4
3	6
4	8
5	10
6	12

When I plot the data I get a nice curve.

However what I want is to get the Y-value for a given X-value. Is it possible to extract.

Additionaly, the (X,Y) pair may not be explicity present in the file.

For eg X = 4.5 in the above case. Is it possible to get the Y value for X = 4.5 from the above data set and store it in a variable.

Thanks in advance

[toc] | [next] | [standalone]


#649

FromOliver Jennrich <oliver.jennrich@gmx.net>
Date2011-10-19 23:38 +0200
Message-ID<yg1lisgy85h.fsf@ID-371.news.uni-berlin.de>
In reply to#648
Naren <a.narendiran@gmail.com> writes:

> I have a data file containg values of X and Y data.
>
> Example (Y = 2X)
>
> X	Y
>
> 1	1
        2, I assume
> 2	4
> 3	6
> 4	8
> 5	10
> 6	12
>
> When I plot the data I get a nice curve.
>
> However what I want is to get the Y-value for a given X-value. Is it
> possible to extract.

No, not in the general case. However,...
>
> Additionaly, the (X,Y) pair may not be explicity present in the file.
>
> For eg X = 4.5 in the above case. Is it possible to get the Y value
> for X = 4.5 from the above data set and store it in a variable.


... in this case (linear function) you can calculate the inverse
function f^-1(y) 

y=f(x)=ax+b   =>  x = f^-1(y) = (y-b)/a

by fitting a and b to the dataset:

f(x)=a*x+b
g(y)=(y-b)/a

fit f(x) 'datafile' via a,b

print g(4.5)


-- 
Space - The final frontier

[toc] | [prev] | [next] | [standalone]


#651

FromNaren <a.narendiran@gmail.com>
Date2011-10-20 00:05 -0700
Message-ID<23530315.40.1319094331983.JavaMail.geo-discussion-forums@prms22>
In reply to#649
The example i gave is only to illustrate my problem. My data actually does not follow any predictable standard fuction. I do not know what function to fit the data to.

[toc] | [prev] | [next] | [standalone]


#656

FromHans-Bernhard Bröker <HBBroeker@t-online.de>
Date2011-10-21 22:54 +0200
Message-ID<9ge4f9Fl4sU2@mid.dfncis.de>
In reply to#651
On 20.10.2011 09:05, Naren wrote:

> The example i gave is only to illustrate my problem. My data actually
> does not follow any predictable standard fuction. I do not know what
> function to fit the data to.

In that case, you really should have stopped for a moment to think about 
whether hat you're trying to do actually can be done at all, with any 
useful degree of reliability.

If you don't have any idea what function those data might be supposed to 
follow, then the thing you asked for:

 > _the_ Y-value for a given X-value [emphasis mine]

is not defined, and any method you come up with to compute it has to be, 
by definition, incorrect.

[toc] | [prev] | [next] | [standalone]


#650

Fromsfeam <sfeam@users.sourceforge.net>
Date2011-10-19 14:42 -0700
Message-ID<j7ng93$t8u$1@dont-email.me>
In reply to#648
Naren wrote:

> I have a data file containg values of X and Y data.
> 
> Example (Y = 2X)
> 
> X	Y
> 
> 1	1
> 2	4
> 3	6
> 4	8
> 5	10
> 6	12
> 
> When I plot the data I get a nice curve.
> 
> However what I want is to get the Y-value for a given X-value. Is it
> possible to extract.
> 
> Additionaly, the (X,Y) pair may not be explicity present in the file.
> 
> For eg X = 4.5 in the above case. Is it possible to get the Y value for X
> = 4.5 from the above data set and store it in a variable.

The generic answer is that whenever you click on the plot display with
the mouse (assuming you are using an interactive display mode, of course)
it saves information about the mouse-click in a set of special variables.
Here's what I get after opening up a plot and clicking the mouse in it.
gnuplot> show variable MOUSE
        Variables beginning with MOUSE:
        MOUSE_X = 2.23883206574001
        MOUSE_Y = -3.34830115252208
        MOUSE_X2 = 2.23883206574001
        MOUSE_Y2 = -3.34830115252208

You can do much more than that, however.  For instance if I tell gnuplot
gnuplot> pause mouse key
Then typing a character in the plot window will save not only the coordinates
but also information about what was typed.  Here I type the "A" key:
gnuplot> show variable MOUSE
        Variables beginning with MOUSE:
        MOUSE_X = 2.23883206574001
        MOUSE_Y = -3.34830115252208
        MOUSE_X2 = 2.23883206574001
        MOUSE_Y2 = -3.34830115252208
        MOUSE_SHIFT = 0
        MOUSE_ALT = 0
        MOUSE_CTRL = 0
        MOUSE_KEY = 65
        MOUSE_CHAR = "A"

In the gnuplot distribution there is a demo script called
  mouselabels.dem
that shows how you can set up a script to interact with a plot using
the mouse, including saving the coordinates of specific points that you
have clicked on.

[toc] | [prev] | [next] | [standalone]


#652

FromNaren <a.narendiran@gmail.com>
Date2011-10-20 00:08 -0700
Message-ID<15457819.543.1319094520134.JavaMail.geo-discussion-forums@prng5>
In reply to#650
I want automate the process without requiring user interaction ... As I have lots of data files and I need to repeat the action in every file.

[toc] | [prev] | [next] | [standalone]


#653

FromJames Cloos <cloos@jhcloos.com>
Date2011-10-20 19:34 -0400
Message-ID<m3k47zb5kl.fsf@jhcloos.com>
In reply to#652
>>>>> "N" == Naren  <a.narendiran@gmail.com> writes:

N> I want automate the process without requiring user interaction ...
N> As I have lots of data files and I need to repeat the action in every file.

Then gnuplot is not what you are looking for.

Try R, octave, scilab, sage or the like.  Or perl, python, ruby, java, et cetera.

All of those can fit a function to a set a data which you can then use
to map inputs to outputs.

(Some of those projects can (optionally) use gnuplot to render plots.)

Links include:

http://www.r-project.org/
http://www.octave.org/
http://www.scilab.org/
http://www.sagemath.org/

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6

[toc] | [prev] | [next] | [standalone]


#654

FromIngo Thies <ingo.thies@gmx.de>
Date2011-10-21 09:02 +0200
Message-ID<9gcjnkFe0eU1@mid.individual.net>
In reply to#652
On 20.10.2011 09:08, Naren wrote:
> I want automate the process without requiring user interaction ...
> As I have lots of data files and I need to repeat the action in every file.

Hmm, did you consider to do a plot with the 'smooth acspline' option
(instead of 'with lines') and to redirect the data with 'set table
"filename"' into a file? Maybe the file format will be a bit unexpected
(gnuplot doesn't output multiple columns, but blocks stacked above each
other, but if you know the number of your data points, this should be a
minor problem).

Anyway, doing this via an external script or program seems to be much
more convenient to me.

HTH,

Ingo

[toc] | [prev] | [next] | [standalone]


#657

Fromab <ab.3942@googlemail.com>
Date2011-10-27 00:46 -0700
Message-ID<e814a4cc-0089-4270-b40b-6520690dcbe5@l19g2000yqm.googlegroups.com>
In reply to#648
If you know the sampling rate of your function you can calculate the
data point below and above the x-value  you are interested in.

you end up with two x-values from your date file  x1  <  x   < x2
Now you do a linear  with your data    the interval [x1:x2]
The fitted function  can be used to calc  f(x)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web