I found these neat little additions here, but I'm having a hard time reading the code:
\makeatletter
\def\pgfplotsutil@decstringcounter#1{%
\begingroup
\c@pgf@counta=#1\relax
\advance\c@pgf@counta by -1
\edef#1{\the\c@pgf@counta}%
\pgfmath@smuggleone#1%
\endgroup
}%
\pgfplotsset{
/pgfplots/each nth point**/.style 2 args={%
/pgfplots/x filter/.append code={%
\ifnum\coordindex=0
\def\c@pgfplots@eachnthpoint@xfilter{#2}%
\def\c@pgfplots@eachnthpoint@xfilter@zero{0}%
\fi
\ifx\c@pgfplots@eachnthpoint@xfilter@zero\c@pgfplots@eachnthpoint@xfilter
\def\c@pgfplots@eachnthpoint@xfilter{#1}%
\else
\let\pgfmathresult\pgfutil@empty
\fi
\pgfplotsutil@decstringcounter\c@pgfplots@eachnthpoint@xfilter
}%
},
}
\pgfplotsset{
/pgfplots/each nth point*/.style 2 args={%
/pgfplots/x filter/.append code={%
\ifnum\coordindex=0
\def\c@pgfplots@eachnthpoint@xfilter{0}%
\edef\c@pgfplots@eachnthpoint@xfilter@cmp{#1}%
\else
\ifnum\coordindex>#2\relax
\pgfplotsutil@advancestringcounter\c@pgfplots@eachnthpoint@xfilter
\ifx\c@pgfplots@eachnthpoint@xfilter@cmp\c@pgfplots@eachnthpoint@xfilter
\def\c@pgfplots@eachnthpoint@xfilter{0}%
\else
\let\pgfmathresult\pgfutil@empty
\fi
\fi
\fi
}%
},
}
\makeatother
I'm familiar with the use of \makeatletter and \makeatother and I'm familiar with programming concepts, but this syntax always gives me trouble.
Does
each nth point**shift the plotted points vertically?I know in general that
each nth point*plots every point at the beginning, then starts plotting every nth point after a specified number of data points.a. Does the first
ifplot the first coordinate and then redefine a variable for the remainder of the data points? Using the first argument?b. Does the first
ifinside the firstelseactivate when the data point corresponding to the second argument is reached?c. Is the rest of the code just from the normal
each nth pointcode, with the nestedelsethrowing out/not plotting the point for any index that gets there?
There is a point (no pun intended) to this exercise. I'd like to alter every nth point* so that it will take 3 arguments instead of two (I presume /.style 2 args= becomes /.style 3 args=) so it can plot every nth point except for a certain region (arg2 < x < arg3) in which every point will be plotted.

/.style 3 args=for more than two arguments there's/.style n args=. – Gonzalo Medina Mar 10 '15 at 16:06/.style n args={3}{code with #1 #2 #3}. – Gonzalo Medina Mar 10 '15 at 20:34