# Increasing error bar in Pgfplots?

I read data from a table to create a plot in Pgfplots:

x    y   sigma
1    2    0.3
2    4.1  0.4


where sigma is the standard error associated with y.

Since y and sigma together are are standard normal estimators, the range [y-sigma,y+sigma] can be interpreted as a 68.3% confidence interval. ([1.7,2.3] in the example.) This is the range for which the standard "error bar" is shown if you add errors to the data points in PGFplots. Now, I would like to instead show the range [y-1.96*sigma,y+1.96*sigma], corresponding to the 95% confidence interval. One easy way would be to add a row to the table:

x    y   sigma  r95
1    2    0.3   0.588 %=1.96*0.3
2    4.1  0.4   0.784 %=1.96*0.4


and then use r95 as variable for the errors. But in my case, that would be a lot of work. Is there a way to accomplish the same from within PGFPlots, without changing the tables? My current PGF plots is something like:

\begin{axis}[
height=6cm,
width=8cm,
grid=major,
title=Figure title,
xlabel=The $x$ axis,
ylabel=The $y$ axis,
legend pos=north west,
]
\addplot+[only marks,mark=asterisk,error bars/.cd,y dir=both,y explicit]
table [x=x,y=y,y error = sigma] {data.txt};
\legend{$S$}
\end{axis}

-

You can use a mathematical expression for the error bars if you say y error expr=\thisrow{sigma}*1.96 instead of y error=sigma:

\documentclass{article}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
height=6cm,
width=8cm,
grid=major,
title=Figure title,
xlabel=The $x$ axis,
ylabel=The $y$ axis,
legend pos=north west,
]
\addplot+[only marks,mark=asterisk,error bars/.cd,y dir=both,y explicit]
table [x=x,y=y,y error expr= \thisrow{sigma}*1.96] {
x    y   sigma
1    2    0.3
2    4.1  0.4
};
\legend{$S$}
\end{axis}
\end{tikzpicture}

\end{document}

-
Thanks, that saves an awful lot of work. I tried something like this, but didn't find the "Mathematical Expressions And File Data" section in PGFPlots; very useful. – willem Apr 25 '13 at 9:21