# pgfplots fill between and smooth don't work

I've been trying to fill the area between two curves plotted with pgfplots. The graphs are plotted from an external .dat file attached to the link below. The fill between command does not work for some reason.

In addition the smooth command (with tension adjusted) does not work. Same problem with samples.

Does anyone have an idea to work around those two problems?

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

\begin{document}

\begin{tikzpicture}
\pgfplotsset{
style/.style={mark=none,unbounded coords=jump}}
\begin{axis}[width=\textwidth, height=10cm ]
\addplot table[style, x index = {0}, y index = {1}]{\data};
\addplot table[style, x index = {2}, y index = {3}]{\data};
%\addplot table[style, domain=80:100,name path=A, x index = {0}, y index = {1}]{\data};
%\addplot table[style, domain=80:100, name path=B, x index = {2}, y index = {3}]{\data};
\addplot table[style, x index = {4}, y index = {5}]{\data};
\addplot table[style, x index = {6}, y index = {7}]{\data};
\addplot table[style, x index = {8}, y index = {9}]{\data};
\addplot table[style, x index = {10}, y index = {11}]{\data};
\addplot table[style, x index = {12}, y index = {13}]{\data};
\end{axis}
\end{tikzpicture}

\end{document}


.dat file

You can just change this line and the graph will be much smoother:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}

\begin{document}

\begin{tikzpicture}
\pgfplotsset{
style/.style={mark=none,unbounded coords=jump}}
\begin{axis}[width=\textwidth, height=10cm, smooth]]

\addplot table[style, x index = {0}, y index = {1}]{\data};
\addplot table[style, x index = {2}, y index = {3}]{\data};
%\addplot table[style, domain=80:100,name path=A, x index = {0}, y index = {1}]{\data};
%\addplot table[style, domain=80:100, name path=B, x index = {2}, y index = {3}]{\data};
\addplot table[style, x index = {4}, y index = {5}]{\data};
\addplot table[style, x index = {6}, y index = {7}]{\data};
\addplot table[style, x index = {8}, y index = {9}]{\data};
\addplot table[style, x index = {10}, y index = {11}]{\data};
\addplot table[style, x index = {12}, y index = {13}]{\data};
\end{axis}
\end{tikzpicture}

\end{document}


The result is this:

• That did in fact work, thanks! Oct 16 '21 at 13:35
• If you like the solution then please don't forget to vote. Thanks! Oct 16 '21 at 15:52
\documentclass[border=1 cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}
\begin{filecontents}{druckabfall_neu_test.dat}
1;11;1;21;1;31;1;41;1;51;1;61;1;71
2;12;2;22;2;32;2;42;2;52;2;61;2;72
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{style/.style={mark=none, unbounded coords=jump}}
\begin{axis}[width=\textwidth, height=10cm, smooth]
\addplot[style, name path=A] table[x index = {0}, y index = {1}]{\data};
\addplot[style, name path=B] table[x index = {2}, y index = {3}]{\data};
\addplot fill between [of=A and B];
\addplot[style] table[x index = {4}, y index = {5}]{\data};
\addplot[style] table[x index = {6}, y index = {7}]{\data};
\addplot[style] table[x index = {8}, y index = {9}]{\data};
\addplot[style] table[x index = {10}, y index = {11}]{\data};
\addplot[style] table[x index = {12}, y index = {13}]{\data};
\end{axis}
\end{tikzpicture}
\end{document}


Edit: The external data

• Thanks, that works for me as well. But not for the actual data I want to plot!? Oct 16 '21 at 15:29
• @maximus: How does it not work? I have tested it with the file, you link to and it works. I do not know what data you else want to plot!? -anyway, it should not be needed to link external data here on this site. Oct 16 '21 at 15:52
• @hpwkristiansen It works now. When I first wrote my code I compiled every single line to see if everything works fine. The final plot had all the graphs plotted in different colors. Weirdly the plot you posted here doesn't have all those colors allthough it doesn't seem to be indicated in the code somewhere. So when I copied the whole code back from your post it just worked instantly. The codes are exactly the same though. Don't know what happened but thanks for your help anyway! Oct 17 '21 at 9:09