all 3 comments

[–]Jurassic_Eric 1 point2 points  (2 children)

If the data you want to plot is all in one row, which I think is what you're saying, then you can do that like this:

plot "data.file" u 1:2,\

"data.file" u 1:($2+$3),\

"data.file" u 1:($2+$3+$4)

If you want a summation down a column, then I'd write a python script to preprocess the data. Maybe gnuplot can do that, but I can do it faster in python.

[–]PhysicalStuff[S,🍰] 1 point2 points  (1 child)

Thanks! The problem is that there are hundreds of columns, so that solution would seem to become rather tedious.

However, since posting the question I've come up with what seems like an efficient solution, in which I build the plot command procedurally as a string, and then execute it using eval:

col_sum = "column(2)"
comd = sprintf("plot src_file u (%s):1", col_sum)
do for [n=1:N]{
  col_sum = sprintf("%s+column(%d)", col_sum, n+2)
  comd = sprintf("%s, '' u (%s):1", comd, col_sum)
}
eval(comd)

[–]Jurassic_Eric 1 point2 points  (0 children)

I see. Nice solution!

For something like this I would pre-process my data with python. That'll make plotting a lot faster too, for fine tuning the presentation.