TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

        /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:

    xlabel={}, ylabel={},%
    legend cell align=left]

            file {data1.dat};
            file {data2.dat};

    \caption[]{} \label{}
share|improve this question
up vote 9 down vote accepted

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.

share|improve this answer
I tried and I obtains this error: ./Figures/figure1.tex:10: Package pgfplots Error: Could not read table file 'Da ta/figure1.dat'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try row sep=crcr' and terminate your lines with \\' (r efer to the pgfplotstable manual for details). What it means? – R. M. Sep 30 '12 at 14:15
What TeX implemention you use? – m0nhawk Sep 30 '12 at 14:27
I use MacTex-2012 – R. M. Sep 30 '12 at 14:29
Check the newline character, for Mac this is LF. If you obtain data file from other sources (Windows or other OSes) newline character would be other - CR+LF, LF+CR, or just CR. And TeX is really frustrated with changing newline character in different parts of document. – m0nhawk Sep 30 '12 at 14:36
How I check the newline character? I created the file with emacs on Mac OS X. The file contains the three lines I posted on the question... – R. M. Sep 30 '12 at 14:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.