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:
\documentclass
and 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=4
to ensure that your graph is properly formatted (except for theprint last
part).data.dat
todata.data
works so not sure what is going on.data.dat
file 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.