Is there any way to adapt Show last N rows from input datafile only in \pgfplotstabletypeset to a \addplot table command ?
This doesn't work:
\documentclass{article}
\usepackage{pgfplots}
\usepackage{filecontents}
\begin{document}
\begin{filecontents}{data.dat}
1 5
2 3
3 6
4 4
5 0
6 1
\end{filecontents}
\pgfkeys{
/pgfplots/table/print last/.style={
row predicate/.code={
% Calculate where to start printing, use `truncatemacro` to get an integer without .0
\pgfmathtruncatemacro\firstprintedrownumber{\pgfplotstablerows-#1}
\ifnum##1<\firstprintedrownumber\relax
\pgfplotstableuserowfalse
\fi
}
},
/pgfplots/table/print last/.default=1
}
\begin{tikzpicture}
\begin{axis}[x=1cm]
\addplot table {data.dat};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[x=1cm]
\addplot table [print last=4] {data.dat};
\end{axis}
\end{tikzpicture}
\end{document}
Both plots are the same:



\documentclassand the appropriate packages so that those trying to help don't have to recreate it. Also, in this case you should also show a line without theprint last=4to ensure that your graph is properly formatted (except for theprint lastpart). – Peter Grill Nov 18 '11 at 17:56data.dattodata.dataworks so not sure what is going on. – Peter Grill Nov 18 '11 at 18:50data.datfile name, even though I checked the file and it appears to be fine... Anyway, my problem is unrelated to yours, so thanks for putting together a MWE. – Peter Grill Nov 18 '11 at 21:29row predicateonly applies to table typesetting. The plot tools rely on on "coordinate filtering". Perhaps a suitable solution would useskip coords between index={begin}{end}. Perhaps I can elaborate this later (unless someone has more time) – Christian Feuersänger Nov 19 '11 at 08:57