5

With this example document

\documentclass[tikz,12pt]{standalone}

\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{fillbetween}

\pgfplotsset{compat=1.12} 

\begin{document}

\begin{tikzpicture}
\begin{axis}[ 
    % error bars/y dir=both,
    error bars/y explicit, 
    ]

    \addplot[blue,name path=A,smooth] {x^2};
    \addplot[red,name path=B,smooth]  {x^2+1};
    \addplot[gray!50] fill between[of=A and B];

\end{axis}
\end{tikzpicture} 

\end{document}

the output looks as expected: enter image description here

If I additionally add more data and enable the error bars/y dir=both the example fails to compile. Is this a bug or am I doing something wrong?

  • This is a bug, thanks for the report. I will take a note on my todo list. A workaround could be to plot the same plot twice, once without error bar (but with name path) and once only with the error bar. – Christian Feuersänger Dec 3 '15 at 16:56
3

This is a bug. Thanks to your report, I have identified and fixed it; will become part of pgfplots 1.13.

A workaround is to draw the path twice, once with name path and without error bars and once without name path but with error bars:

\documentclass{standalone}

\usepackage{tikz,pgfplots}
\usepackage{pgfplotstable}
\usepgfplotslibrary{fillbetween}

\pgfplotsset{compat=1.12} 

\begin{document}

\begin{tikzpicture}
\begin{axis}[ 
    error bars/y dir=both,
    error bars/y fixed=1, 
    ]

    \addplot[blue,smooth] {x^2};
    \addplot[red,smooth]  {x^2+1};
    \addplot[draw=none,error bars/y dir=none,name path=A,smooth] {x^2};
    \addplot[draw=none,error bars/y dir=none,name path=B,smooth]  {x^2+1};
    \addplot[gray!50] fill between[of=A and B];

\end{axis}
\end{tikzpicture} 

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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