Population Xplosive
Population Xplosive

Reputation: 617

How to fix gnuplot -e "plot 'file' u 1:($2)-1 w l" syntax?

I need to plot files using gnuplot without going to gnuplot terminal. So, I am taking a quick look at the plots using the following line.

i=2; while [ $i -le 14 ] ; do gnuplot -e "plot 'pop05' u 1:$i w l, 'pop01' u 1:$i w l; pause 2"; ((i++)); done

However, gnuplot -e does not seem to work for the cases of

gnuplot -e "plot 'pop01' u 1:($2)-1 w l"

ie, when I try to use an altered value in a particular column like I subtract 1 from the second column. However, plot 'file' u 1:($2)-1 w l works perfectly in gnuplot terminal. What should be the syntax for me to plot an altered column in the loop as well as without the loop? I use gnuplot 4.4 patchlevel 3.

Upvotes: 0

Views: 795

Answers (1)

choroba
choroba

Reputation: 242383

$2 has a special meaning in shell in double quotes (it returns the second positional argument). Just backslash the dollar sign:

gnuplot -e "plot 'pop01' u 1:(\$2)-1 w l"

Upvotes: 1

Related Questions