Wrong output from mod in axis
Brought to you by:
cfeuersaenger,
ludewich
This comes from https://tex.stackexchange.com/questions/395239/align-bar-graph-with-error-bars-in-groups-on-y-axis?noredirect=1#comment988105_395239
Basically the problem is that mod(N,3) sometimes gives 3 as the answer, when it should give zero. The example (output atttached) below shows this, and shows also that the same thing does not happen with \draw plot in plain TikZ.
I haven't done any other testing.
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=16cm,height=4cm,
xtick distance=3,minor tick num=2,grid=major
]
\addplot [mark=*,only marks,samples at={0,1,...,60},nodes near coords={\pgfmathprintnumber[precision=0,fixed]{\pgfplotspointmeta}}] {mod(x,3)};
\end{axis}
\begin{scope}[xscale=0.25,yshift=-4cm]
\draw plot[samples at={0,1,...,60},only marks,mark=*] (\x,{mod(\x,3)});
\foreach \x in {0,3,...,60}
\draw [help lines,dotted] (\x,2) -- (\x,0) node[below]{\x};
\end{scope}
\end{tikzpicture}
\end{document}
Thanks for the detailed problem report! I have found and fixed the problem.
The floating point library used a pseudo-integer truncation routine which failed. I added correct integer arithmetics.
The fix will come with the next version of pgfplots or pgf, whichever is released first.