# Force re-reading a data file

I have a data file from which I want to plot odd/even rows seperately, in the same axis. But the table options seem to apply only once, when reading in the data, which only happens once per axis (i.e. after a \nextgroupplot the data seems to be read again, or in a new tikzpicture).

\documentclass{article}
\usepackage{pgfplots}
\begin{filecontents}{data.dat}
1 1
2 4
3 3
4 8
\end{filecontents}
\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot[only marks] table[each nth point=2, skip first n=1]{data.dat};
\end{axis}
\end{tikzpicture}

should be:

\begin{tikzpicture}
\begin{axis}
1 1
3 3
};
2 4
4 8
};
\end{axis}
\end{tikzpicture}
\end{document}


Is there an option to force re-reading the data for each table command?

-

I don't think you can use skip first n key to filter the coordinates in a flexible fashion as it is a pgfplotstable key for either reading the table or typesetting it. Instead you can use filters to eliminate the odd/even numbered rows

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{filecontents}{data.dat}
1 1
2 4
3 3
4 8
\end{filecontents}
\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot[no markers,each nth point=2] table {data.dat};

\ifodd\numexpr\coordindex+1\relax
\def\pgfmathresult{}
\fi}
] table {data.dat};
\end{axis}
\end{tikzpicture}

\end{document}


Of course with this code you can cook up your own filters (by using Mod(,) etc.) so it is doable anyways.

-
Ok, I thought the point of the table keys was exactly this kind of filtering (like gnuplot's every <skip>:<start>:…), so it's just a side-effect? –  pascal Apr 13 '13 at 0:28
@pascal I think it's more of a row downsampling while reading, column creating and/or typesetting the data. As you can see you can introduce the same functionality (or maybe I don't know in case it already exists). I think this is also easy to introduce so you can file a feature request for that. –  percusse Apr 13 '13 at 0:42