# plot points depending on x value?

Is there any options to replace each nth point={100} for something dependent on column value?

My table is something like:

x   y
0   5
1   4
2   5
3   3
3   -3
2   -4
1   -1
0   0


I just want to plot for x values lower than 2.

(Of course it is a minimial situation, in the complete situation it is not so easy to modify the table and I use the other values inside the same axis).

Here is the first option using restrict x to domain=0:2

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
x   y
0   5
1   4
2   5
3   3
3   -3
2   -4
1   -1
0   0
}\mydata

\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot+[restrict x to domain=0:2] table [x=x,y=y]
{\mydata};
%
\end{axis}
\end{tikzpicture}

\end{document}


And using xmax

\documentclass{article}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
x   y
0   5
1   4
2   5
3   3
3   -3
2   -4
1   -1
0   0
}\mydata

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=2]

There is always a possibility that you can write some complex comparing routine using x expr macro, but I will leave it now.