I am thinking which way to do the addition of errorbars better by thinking the format of data. The standard way of adding errors bars is discussed here, for instance.
First of all, I wonder about your columns used for plotting with yerrorlines
. If your first data for 2025 is 75.5+/-2.5, you usually plot it with
plot "datafile" using <xcolum>:<ycolum>:<yerrorcolumn>
Your six columns are for the case of xy errorbars and specify the point itself and the lower and upper absolute values in x and y. But may be you are just doing it as you need it...
Now back to your question: Gnuplot can not handle data from two files simultaneously, i.e. it can not take xy-values from one file and y-errors from another.
If you're running linux, the command line tool join
can help.
Your averages stored in file A and the errors in file B, join A B
will concatenate lines with the same value in the first colum like this:
2025 75.5 82.5 89.5 2.5 2.5 2.5
So,
plot "<join A B" using 1:2:5 with yerrorlines
should do the job. ("<join A B"
will call the join command in the background and read its output like a data file)
Gnuplot 5 supports that you specify several characters as data file separators.
So, if you are sure you'll never get negative values (which I hopen given the format of your data), then you can use your original data file and set both white space and hyphen as datafile separator:
set datafile separator " -"
plot for [i=2:6:2] "data" using 1:(0.5*(column(i)+column(i+1))):(0.5*(column(i+1)-column(i))) with yerrorlines