The each nth point = \n option of PGFPlots allows to sample data points in a list, keeping only the points indexed 2n+1 (with n=0,1,...).
I would like to be able to extract the points with indices 2n+m (similarily to the option mark phase = m and mark repeat = n).
Here is my unsuccessful attempt, where somehow, the command skip coords between index={0}{\m} seems to be ignored:
\begin{filecontents}{pts.dat}
x y
1 0
0.5 0.866
-0.5 0.866
-1 0
-0.5 -0.866
0.5 -0.866
1 0
\end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[no marks]
\addplot[ultra thick, dashed, lightgray] table {pts.dat};
\foreach \n in {0,3}
\foreach \m in {1,\n}
{
\addplot[
skip coords between index={0}{\m},
each nth point=\n,
filter discard warning=false,
unbounded coords=discard
] table {pts.dat};
}
\end{axis}
\end{tikzpicture}
\end{document}

\foreachinsideaxiswithout careful consideration. - use\pgfplotsinvokeforeach, but do not nest it. – hpekristiansen Jul 05 '22 at 16:36