gnuplot with errorbars plotting

user506901 picture user506901 · May 21, 2012 · Viewed 54.2k times · Source

The data in my "file.txt" file are as in the following (sample row shown)

31 1772911000 6789494.2537881

Note that the second column is the mean and the third is the standard deviation of my input sample. So, for the error bar, I would need the bar at the x axis value 31, with the error bar start at (second column value)-(third column value), and end at (second column value)+(third column value). I tried the following:

plot "file.txt" using ($1-$2):1:($2+$1) with errorbars

but the result is inappropriate. Any help?

Answer

Phil H picture Phil H · May 21, 2012

You need x:y:err, so try

plot "file.txt" using 1:2:3 with yerrorbars

yerrorbars

You may instead want candlesticks. These are generally a box with error bars extending out of the top and bottom, but setting the mins and maxes the same should give you boxes of the required size:

plot "file.txt" using 1:($2-$3):($2-$3):($2+$3):($2+$3) with candlesticks

candlesticks