Reputation: 407
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?
Upvotes: 3
Views: 4885
Reputation: 48440
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
Upvotes: 2
Reputation: 408
yes ! First of all replace each ; by a blank then try this command
plot "your_data_file" using ($1):(($2+$3)/2)
Upvotes: 0