The problem here is that the function isn't evaluated within the axis range. The standard domain
is -5:5
(this is not changed by setting xmin
and xmax
), so with 60 samples, the function is evaluated at 3.98 and 4.15. If you set the domain=4:4.001
(so equal to the visible range set using xmin
and xmax
), the data is plotted correctly without any manual coordinate transformations:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
compat=newest,
samples=60,
xmin=4.0, xmax=4.001,
domain=4:4.001,
xlabel=Time $t$,
ylabel=Acceleration $a$,
ticklabel style={ % Make sure all relevant digits are printed
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=4
}
]
\addplot [very thick, blue] {5*x-x^2};
\end{axis}
\end{tikzpicture}
\end{document}