\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
With each nth point**={integer}{integer} you can specify the offset by the second number. With each nth point*={integer}{integer} you can specify by the second number how many sampes in the beginning are plotted (without being skipped).
When using filters with pgfplots, it is useful to turn off the filter messages:
\pgfplotsset{filter discard warning=false} %Turn off filter messages
Keine Kommentare:
Kommentar veröffentlichen