Why does mod(x,4) is 4 when x = {12, 24, 32}? should be 0, as in x = 4 and x = 8.
\documentclass{article}
\usepackage[a4paper, total={6in, 9in}]{geometry}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis x line = middle,
axis y line = left,
style={draw=none},
xmin=-0, xmax=32,
ymin=-1, ymax=6, width=15cm,height=10cm,
ylabel=$y$,
xtick={0,1,...,32},
%ytick=\empty,
xlabel=t]
\addplot+[const plot,samples at={0,1,...,32}] {(mod(x,4))};
\end{axis}
\end{tikzpicture}
\end{document}

pgfplotsit should work as expected. – Torbjørn T. Feb 23 '20 at 19:49