6

MWE:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{fillbetween}

\usepackage{filecontents}

\begin{filecontents}{testdata.dat}
t lineLow lineHigh lineMedian
0 1 1 1
1 2 2 2
2 2 3 2.5
3 2 4 3
4 2 4 3
\end{filecontents}

\begin{document}

\begin{tikzpicture}
    \begin{groupplot}
    [
        group style={group size=1 by 2, vertical sep=30pt}
    ]
        \nextgroupplot
        [
        ]

        \addplot[name path=lineLow] table[x=t, y=lineLow] {testdata.dat};
        \addplot[name path=lineHigh] table[x=t, y=lineHigh] {testdata.dat};
        \addplot[fill=red] fill between[of=lineLow and lineHigh];
        \addplot table[x=t, y=lineMedian] {testdata.dat};
    \end{groupplot}
\end{tikzpicture}

\begin{tikzpicture}
    \begin{axis}
        \addplot[name path=lineLow] table[x=t, y=lineLow] {testdata.dat};
        \addplot[name path=lineHigh] table[x=t, y=lineHigh] {testdata.dat};
        \addplot[fill=red] fill between[of=lineLow and lineHigh];
        \addplot table[x=t, y=lineMedian] {testdata.dat};
    \end{axis}
\end{tikzpicture}

\end{document}

Problem: the fill area between the lines does not work inside groupplots. Is there a workaround for this?

Versions:

  • pgf 3.0.0
  • pgfplots 1.11

closed as off-topic by Stefan Pinnow, Henri Menke, Martin Schröder, user13907, Sean Allred Aug 14 '16 at 20:34

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Any chances to get this working? I'd really like to use it in my paper. – remus Oct 29 '14 at 13:25
  • 4
    I'm voting to close this question because it is solved by updating PGFPlots to v1.14 – Stefan Pinnow Aug 14 '16 at 19:47
4

This is a bug in pgfplots 1.11. I downgraded to pgfplots 1.10 and everything looks as expected.

  • 8
    The bug appears to be related to layered graphics, more specifically to cell picture=false. If you add set layers,cell picture=true, to your groupplot, it will also work for 1.11 . I will look into it. – Christian Feuersänger Nov 14 '14 at 15:50
  • @ChristianFeuersänger Are there any updates on this? I just came across this same bug and I'm using pgfplots 1.12. Good that I found this comment of yours for a workaround! – jja May 12 '15 at 18:18
  • No, this is still current at the time of this writing (latest stable 1.12.1). – Christian Feuersänger May 13 '15 at 18:37
3

The bug has been fixed in pgfplots version 1.13. With 1.13, the example compiles as expected without any changes: enter image description here

At the time of this writing (January 9, 2016), version 1.13 is quite fresh and might need a couple of days until it arrives in all TeX package managers.

  • Unfortunately, fillbetween still does not seem to work correctly in all sub-plots inside a group plot on my setup even with PGFPlots 1.13. For instance, this LaTeX file results in this PDF file. Could you please take a look at it? – ib. Jan 10 '16 at 8:03
  • Another appearance of the same issue: tex.stackexchange.com/q/287424 – LaRiFaRi Jan 13 '16 at 13:31
  • 1
    @ib I have analyzed your issue and found that it is caused by a different, unrelated root cause. Apparently, two axes in the same figure suffer from the fact that the first fill between installs a clip path -- and the second is clipped away. This is clearly a bug and I will take care of it. A workaround is to add clip=false to the groupplot environment. – Christian Feuersänger Jan 13 '16 at 19:12
  • @LaRiFaRi my last comment (and workaround) applies to your example as well. – Christian Feuersänger Jan 13 '16 at 19:15

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