[Tex/LaTex] pgfplots and errorbars

pgfplots

I have a file containing data points that I plot using gnuplot. The file looks as follows:

0.1 0.2 0.001
0.2 0.4 0.001
0.3 0.6 0.001

The first column represent the x axis, the second column represent the y axis and the third column represent the error over the y data.

It is possible to plot such a file, including error bars, using pgfplots and without changing it? If I have a file with four columns (x data, y data, x error, y error) the same solution apply?

This is my configuration for pgfplots:

\usepackage{pgfplots}
    \pgfplotsset{%
        compat=newest,%
        /pgf/number format/use comma,%
        /pgf/number format/1000 sep={\,},%
        /pgf/number format/min exponent for 1000 sep=4}

And this is the code I usually use to create a graph:

\begin{figure}
\centering
    \begin{tikzpicture}
    \begin{axis}[xmin=0,xmax=1000,ymin=0,ymax=1000,title={},%
    xlabel={}, ylabel={},%
    legend cell align=left]

        \addplot[red,thick]
            file {data1.dat};
        \addplot[blue,thick]
            file {data2.dat};

        \legend{,}
    \end{axis}
    \end{tikzpicture}
    \caption[]{} \label{}
\end{figure}

Best Answer

There exist options to explicitly set the error-bars.

/pgfplots/error bars/x dir=none|plus|minus|both
/pgfplots/error bars/y dir=none|plus|minus|both
/pgfplots/error bars/z dir=none|plus|minus|both

Try to adding this options to \addplot.

UPD: Replace the file {data.dat} with table[x index=0, y index=1, y error index=2]{data.dat}, that would set x to first column, y for second and y error to third column. No file needed to be changed.