1

Let's say I have the following data stored in the file 'file' (exciting!):

a_0 a_1 a_2 a_3
b_0 b_1 b_2 b_3
...

and also a given function f. I want to draw several plots, one after the other, each consisting of a single point in (x,y) coordinates : a_2,f(a_2), then b_2,f(b_2), etc.

I want to use a gnuplot-only solution (and I think there must be one, although I can't find it !).

I am looking for something like :

plot 'file' every ::0::0: using ($2):(f($2))
pause -1
plot 'file' every ::1::1: using ($2):(f($2))
...

I seem to be doing something too complicated... Thanks for any help !

4
  • The column numbers start at 1, 0 is the row number. So with plot 'file' every ::0::0 using 3:(f($3)) it should work fine. Commented Mar 24, 2014 at 22:28
  • Yes you're right Christoph. But it's a typo I made ! Your suggestion doesn't work either. Commented Mar 25, 2014 at 6:33
  • @Christoph I really want to draw a single point. Commented Mar 25, 2014 at 6:41
  • Yes, I understood that. And I don't see the problem or error you're having with it. See my answer for a working example. Commented Mar 25, 2014 at 7:34

1 Answer 1

2

The following works fine for me. Take a data file file:

0 1 2 3 4 
5 6 7 8 9

And then use:

f(x) = x**2
plot 'file' every ::0::0 using 3:(f($3))

That plots me a single point at (2, 4). For an automatic iteration use e.g.

stats 'file' using 0 nooutput
do for [i=0:int(STATS_records-1)] {
    plot 'file' every ::i::i using 3:(f($3))
    pause -1
}
Sign up to request clarification or add additional context in comments.

13 Comments

Dear Christoph, it works now ! I removed the ':' at the end, i.e. what works is 'every ::0::0' as you stated and NOT 'every ::0::0:' as I had previously tried. Do you know why ?
I haven't noticed that semicolon at the end. I guess its a limitation of the parsing of the every expression which doesn't allow an ending semicolon. However, this is either a bug in the parsing, or the documenation must be adapted, which currently says: Any of the numbers can be omitted; the increments default to unity... (see help every). But I do also get an error with every ::0::0:, undefined variable using, didn't you get one, too?
With every ::0::0:1 it is OK for me. Is that what you meant ? With every ::0::0: I get the error undefined variable using. I use Gnuplot on a remote machine with version 4.4 patchlevel 2. I agree with your remark on the documentation, as it was my source for my line of code !!
Yes, that's what I meant. I'll report that to the gnuplot developers.
Thanks Christoph. As a matter of fact, my complete command is plot 'file' every ::0::0 using 3:(f($3)),f(x) and I got the following message empty x range [2:2], adjusting to [1.98:2.02] so that I don't get any relevant information for the whole function f... Do you know why Gnuplot does that ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.