17

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?

2 Answers 2

27

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

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. The first worked, but the second produced gnuplot> set style boxplot candlesticks ^ expecting 'data', 'function', 'line', 'fill' or 'arrow' gnuplot>
@user506901 -- It looks (to me from the gnuplot docs) that you would just need plot "file.txt" using ... with candlesticks -- I'm not sure what Phil H was doing with set style boxplot candlesticks ... (I'm using gnuplot 4.4.2), maybe this behavior has changed in 4.6?
@mgilson: You're right, I was trusting my understanding of the help file, I don't use candlesticks often enough to remember. Fixed now, thanks.
@PhilH -- the offending line set style boxplot candlesticks is still there ;-) -- You'll want to remove that line as well.
7

you can also try:

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

($2-$3) is y error bar low value, and ($2+$3) is y error bar high value

However, I think that you should use standard error = standard deviation / square root (sample size), instead of standard deviation, to compute error bars.

1 Comment

Whether to use standard deviation, standard error, or 95% confidence interval for the error bars depends on what you want to convey with your plot. See e.g. a discussion in this paper from Journal of Cell Biology.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.