Data comparison and plotting in gnuplot

1

The data that I have is in this format in the text file :

#REY2_0  REY1_0  alpha1     alpha2   omega

100      200    (-0.1,0)    (1,0)   (0.94379237,-0.052310783)

The list of values is quite long. I need to find the values of REY2_0 and REY1_0 for which the value of the second part of omega is 0 (by second I would mean the value -0.052310783 in the above case). Can I use gnuplot to do this search operation and plot REY2_0 v/s REY1_0 ? Also, as most values are not exactly zero, I would also like to get values of REY2_0 and REY1_0 for which the first three digits are zero (i.e its of the form 0.000xxxxxx)

Abhishek Kumar

Posted 2014-06-09T07:17:55.583

Reputation: 13

Answers

0

Let's we clean your data in advance from ( and ). The linux command sed is a good option (column -t will give a nice format)

  sed 's/[(,)]/\t/g' data.dat | column -t > data02.dat

where we suppose that your original file is named data.dat and that we will create a new file named data02.dat. The new file will have 8 columns. In gnuplot you can access to a single column with the option using ($1):($8) to use data from the first column as x and data from the eighth column for the y.

Now the trick: define a function that will answer with y if it is satisfied a condiction, and with plus infinite if it is not. This because gnuplot will skip the y with values infinite. So in gnuplot you can write

myf(y,t)= t == 0 ? y : 1.0/0.
plot 'data2.dat' us ($1):(myf($2,$8))

Of course you can do this in a more compact way, but to write so IMHO it is more understandable.

For the second question it's possible to set a different condition in the function

myf2(x,y)= ( 0.001 > abs(x) ) && ( 0.001 > abs(y) ) ? y : 1.0/0
plot 'data2.dat' us ($1):(myf2($1,$2))

where abs(x) returns the absolute value of a number (the number without a sign).

Note: ok I was lazy instead of using I write only us. Gnuplot understand it.

Hastur

Posted 2014-06-09T07:17:55.583

Reputation: 15 043