1
votes

I am trying to use gnuplot to plot data in file, in which there are 20 blocks of data with each block 3000 lines, each line 19 columns.

Now I want to sum the first 8 blocks by column and then plot the summed column 1 w.r.t summed column 2+ summed column 3.

How should I do it in gnuplot?

Thank you![enter image description here]1

1

1 Answers

1
votes

If you are using a recent version (>=4.6.0 I think), you can use the stats command. Something like this will give you the column sums for a particular block or range of blocks

stats "datafile.dat" every :::1::1 using 1 name "B11Col1" #Block 1 column 1
stats "datafile.dat" every :::6::8 using 2 name "B68Col2" #Blocks 6-8 column 2
...
stats "datafile.dat" every :::I::J using N name "BIJColN" #Blocks I-J column N

Then you'd access the sums with BIJColN_sum in a plot.

Alternatively, you can do some quick preprocessing in something like octave or take a hackier approach (1, 2, etc) within gnuplot.