The following MWE
\documentclass[beamer,crop]{standalone}
\usepackage{times}
\usepackage{pgfplots,xparse}
\pgfplotsset{
compat=1.17, % Specify the compatibility version
nice_axis/.style={
xlabel={$t/T_c$},
ylabel={$p_{BOC \left( 1,1 \right)}\left( t \right)\cdot \sqrt{T_c}$},
% title={Triangle Function},
grid=both,
axis lines=box,
samples=101,
domain=-2:2,
xmin=-1,
xmax=1,
ymax=1.2,
ymin=-1.2,
ytick={-1, -0.8, ..., 1},
legend pos=outer north east,
}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
nice_axis,
]
\addplot[black, thick, mark=none] coordinates {
(-1,0)
(-0.5,0)
(-0.5,1)
(0,1)
(0,-1)
(0.5,-1)
(0.5,0)
(1,0)
};
\end{axis}
\end{tikzpicture}
\end{document}
Yields
As far as I could see in in other pots, it is due to roundoff error. How to set ytick so that I don't get the zero-imprecision error? I tried this solution but it seems to work for table only.



0.2 + 0.2and0.6 - 0.2are very* slightly different numbers. – hobbs Nov 01 '23 at 21:17