I have a file with 12 columns. I'd like to plot the data with x axis being my 1st column and y axis being the difference between the 2nd and the 8th columns.
I tried plot "test.dat" using 1:(8-2)
but naturally, it is interpreted as 1:6
. How can I do this?
You are missing $
, just add them and they will allow you to reference the column contents
plot "test.dat" using 1:($8-$2) w linespoints
$1
is a shortcut for column(1)
and if the column numbers are stored in variables i
and j
you must use the column
statement to select the respective columns:
i = 8
j = 2
plot "test.dat" using 1:(column(i)-column(j)) w lp