# Applying multiple filters to plot data

I have seen people apply a filter to imported data before plotting with pgfplots, see grouping data in pgfplots. Is there a way to extend the approach presented there to apply multiple filters? In the MWE below I made the naive modifications to the solution given there, but it seems that only the last filter is applied: the unwanted y=1 data points are plotted too.

\documentclass{article}
\usepackage{filecontents}
\usepackage{pgfplots}

\begin{filecontents}{foo.txt}
x y z f
0 0 0 0
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7
\end{filecontents}

\pgfplotsset{
x filter/.code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\ifx\tempa\tempb
\else
\def\pgfmathresult{nan}
\fi
}}
}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
] {foo.txt};
\end{axis}
\end{tikzpicture}
\caption{$f(x)$ given $y=0$ and $z=0$.}
\end{figure}
\end{document}


Of course. You just need to replace .code by .append code in your definition. The first "resets" the command and applies (only) the new stuff while the later - as the name suggests - appends stuff to the previous one.

% used PGFPlots v1.14
\begin{filecontents}{foo.txt}
x y z f
0 0 0 0
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7
\end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
% suppress LOG messages about the filtered points
x filter/.append code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\ifx\tempa\tempb
\else
\def\pgfmathresult{NaN}
\fi
},
},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}