3
votes

My data-file is formatted as fallows:

100;2.123;4.123
100;2.113;5.213
100;2.544;6.234
100;2.324;4.234
200;2.543;3.123
200;2.543;5.123
...

First column is a parameter of a function, second and third are the result of a function. The values of 2nd and 3rd are different for the same values of 1st column, because of other factors, and I want to plot a graph that calculates arithmetic average for all values from 2nd and 3rd column that have the same 1st.

Is there any way gnuplot can do this?

2
My guess is that it would be extremely tricky to do in general, though it would be doable with some constraints on the data. For instance, if each value in the first column always appears four times in sequence. Do you have any such helpful constraints? For arbitrary data I would recommend a separate utility for preprocessing. - andyras
Well - in this particular problem: yes. Each value in the 1st column always appear 4 times in sequence. I'm using excel as a separate utility and I'm not pleased with this solution. - Mirek

2 Answers

2
votes

To calculate the arithmetic average of all values which share the same 1st value, you can use smooth unique. To get the average of all values of the 2nd and 3rd column for the same abscissa, you can use

set datafile separator ';'
plot 'datafile' using 1:(($2+$3)/2.0) smooth unique

That makes the data monotonic in the x-values and then replaces all points with the same abscissa with one point having the averaged y-value.

If e.g. you want only the averaged values of the 2nd columns, you would instead use

plot 'datafile' using 1:2 smooth unique
0
votes

yes ! First of all replace each ; by a blank then try this command

plot "your_data_file" using ($1):(($2+$3)/2)