问题描述:

I'm using gnuplot to plot a file with many columns:

plot for [i=2:119] "./file.dat" using 1:i w l lt 9

It works fine, BUT I'm not able to edit it in order to print the lines shifted.

I'd like to print this, where N is a the shift value

plot for [i=2:119] "./file.dat" using 1:$i+N w l lt 9

but I receive the error( with the ^ on the $):

 gnuplot> plot for [i=2:119] "./file.dat" using 1:$i+1 w l lt 9

"./file.plt", line 182: Column number expected

A work around is to use AWK but also in that case I'm having some errors.

网友答案:

To stay closest to your current script, you can do it as follows

 plot for [i=2:119]  "./file.dat" using 1:(column(i+N)) w l lt  9

I hope it is self-explanatory, but gnuplot help using provides some more info on column()

网友答案:

I find that it gets tricky to remember how to do operations on column numbers which are stored as variables, or if it is even possible. There are two workarounds, though:

1) Change your range

plot for [i=(2+N):(119+N)] "./file.dat" using 1:i ...

2) Use an intermediate variable

do for [i=2:119] {
    ii = i + N
    plot "./file.dat" using 1:ii ...
}
相关阅读:
Top