Reputation: 31
I have a file which have 18 columns. Using gnuplot, I want to plot them in this way: 1:2, 3:4, 5:6, ..., 17:18.
I have been trying with a do loop, but I don't know how to include the running index in the loop in the number of the colums. I tried something like that:
for [i=1:18] plot "numbers.dat" using (2*(i-1)+1):(2*(i-1)+2)
Thanks
Upvotes: 3
Views: 3570
Reputation: 48390
To have the result of an arithmetical expression used as column index, use the column
function:
plot for [i=1:18] "numbers.dat" using (column(2*(i-1)+1)):(column(2*i))
Upvotes: 3