Consider a data file on this format:
x y
0 2
1 3
2 4
0 3
1 5
2 6
0 5
1 7
2 8
The first column repeats it self three times ([0 1 2]) and there are three different data sets here.
A more convenient way to process the file with pgfplots would be in the format:
x y z w
0 2 3 5
1 3 5 7
2 4 6 8
But the software I am using spits out the data in the first format. Is it possible to plot the data on the first format and end up with the same plot as in the following mwe?
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{data.txt}
x y z w
0 2 3 5
1 3 5 7
2 4 6 8
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table [y=y] {data.txt};
\addplot table [y=z] {data.txt};
\addplot table [y=w] {data.txt};
\end{axis}
\end{tikzpicture}
\end{document}
Desired output:
Here's the code with the data on the other format (and the default result):
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{filecontents}{data.txt}
x y
0 2
1 3
2 4
0 3
1 5
2 6
0 5
1 7
2 8
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table [y=y] {data.txt};
\end{axis}
\end{tikzpicture}
\end{document}
Something along the lines of "while x is increasing, continue plot, else start new plot" would do the trick..

