# using more than 2 arguments in a pgfplots style

Based on How to plot data from multiple filters using pgfplots I got a follow up one. I would like to filter not only for one value of P for each plot but for also for X values that are smaller than a given value. Here is how I tried to achieve it.

  \pgfplotsset{
discard if not and smaller/.style 4 args={
x filter/.code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\edef\tempc{\thisrow{#3}}
\edef\tempd{#4}
\ifnum\tempa=\tempb
\ifnum\tempc<\tempd
\def\pgfmathresult{inf}
\else
\fi
\else
\def\pgfmathresult{inf}
\fi
}
}
}

\begin{tikzpicture}
\begin{axis}
\addplot [ultra thick, black, discard if not and smaller={P}{0}{X}{5}] table [x=X, y=Y] {data.dat};
\end{tikzpicture}


But pdfLaTeX tells me that:

! Package pgfkeys Error: I do not know the key '/pgfplots/discard if not and sm
aller/.style 4 args' and I am going to ignore it. Perhaps you misspelled it.


How can I pass these 4 arguments so that pgfplots find the style definition?

More than two arguments require /.style n args={no of args}{....} or /.code n args={no of arguments}{....}

  \pgfplotsset{
discard if not and smaller/.style n args={4}{
x filter/.code={
\edef\tempa{\thisrow{#1}}
\edef\tempb{#2}
\edef\tempc{\thisrow{#3}}
\edef\tempd{#4}
\ifnum\tempa=\tempb
\ifnum\tempc<\tempd
\def\pgfmathresult{inf}
\else
\fi
\else
\def\pgfmathresult{inf}
\fi
}
}
}

\begin{tikzpicture}
\begin{axis}
black,
discard if not and smaller={P}{0}{X}{5}] table [x=X, y=Y] {data.dat};
\end{tikzpicture}


If you have a certain pattern when entering these arguments instead of consecutive braces {1}{2}{3}{4} etc. you can also use

/.style args={#1 and #2 using color #3 and size #4}


or anything else so that you can supply arguments

mykey=a and b using color white and size 2cm


Same holds for /.code args too.