Suppose I have a file with two columns of data file.dat.
I would normally plot it with
plot "file.dat" u 1:2
I want to average over 10 (for example) preceding point and 10 following points, and plot it on the same plot.
I can easily do that using some external script, where I make another column:
for(i=-10;i<=10;++i)
$3[j] += $2[j-i]
However, I’d like to know the way to do it in gnuplot.
My next step would be to do a Gaussian averaging.
This is, perhaps surprisingly, not built in to gnuplot. There is no good way to manipulate individual data points in gnuplot, nor ranges of data points, because of how gnuplot processes the data as a stream.
One great thing about gnuplot is how easy it makes it to call external scripts and tools. If you want to use an external script to process the data from within gnuplot, you can do it like this:
As an example, you could use the python script below. It’s sort of overkill, but you can set the parameter values either hard-coded in the script or at the command line.