Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot if col A has substring

Tags:

gnuplot

I need to do this in gnuplot:

plot 1:4 where col 2=="P1", col 3=="3", col 1 has substring "blur1"

Heres a dataset:

col_1          col_2        col_3    col_4
gcc.blur1.O0   P1           3        10.5
icc.blur1.O2   P2           5        9.8
gcc.blur2.O3   P2           3        8.9

Thanks in advance.

like image 562
jitihsk Avatar asked Aug 09 '26 18:08

jitihsk


1 Answers

AFAIK you need to use an external script to check for substrings. Something like awk and use

plot "< awk '{...awk commands...}' input.dat"

If you just want to test col_2 for P1 you can do it in gnuplot via

f(x,y)= (x eq "P1"? y : 1/0)

plot "input.dat" u 3:(f(strcol(2),$4))

strcol(n) gets the n-ths column as a string. "eq" can be used to compare strings.

like image 169
Arun Avatar answered Aug 11 '26 14:08

Arun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!