3

I need to plot a single point, from a line in data file, that has many other lines and two rows. I don't know how to select a single line in gnuplot, not the entire file of data. Any suggestions please???

2 Answers 2

3

In case the point(s) you want to plot are not characterized by the line number, but by some value in one column, you can use this trick in using :

plot '-' using (($1==0)?$1:1/0):2 with points
-1 1
0  2
1  3
e

This can be used to plot e.g. only points with a positive x-coordinate (change to ($1>=0)?$1:1/0), or also, using the $0 pseudo-column which contains the line number, to select specific lines in a more versatile way than every :

plot 'data.dat' using (((int($0)%3!=0)?$1:1/0):2 with points

Here we plot 2 lines out of 3, of course you can also select one line only with ($0==LINE)?$1:1/0.

1

You have to filter out. In gnuplot this is done with the keyword every.

Since you do not provide the file you want to plot here is a possible hint based on this datafile data.dat:

10 62
11 95
12 74
13 33
14 70

youplot the point at the third line (12,74) like this:

plot 'data.dat' every ::2::2 w p

based on the file structure, this might vary.

Maybe if you have to do it several times it's good to set a variable:

n=2
plot 'data.dat' every ::n::n w p

so that once plotted, you can do:

n=3; replot
n=10; replot
...

Please read carefully the help every command in gnuplot

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.