By default pgfplots has a nasty habit of cutting peaks off
Adding enlarge y limits={abs=0.6pt}
seems to fix this
But now I have an unsightly stub at the ends of my axis
I'd rather like to get rid of this, but can't see how. If someone could point my in the right direction that would be very much appriciated :)
MWE
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{
compat=newest,
no marks,
axis lines=middle,
axis on top,
every axis plot/.append style={very thick},
enlarge y limits={abs=0.6pt}, % prevent clipping of plot lines
}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[domain=0:pi]
\addplot+{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
Issue with the clip=false
solution
This was suggested, and does indeed seem to solve this issue, however it creates another. For asymptotic functions (e.g. changing to 1/x
with ymax=5
) then produce their own set of issues. Given that this is going inside a global setting, I'd rather not have to worry about this.
Issue with shorten inner axis line
When plotting some other functions (e.g. 1/(x+1)), the origin develops a 'gap'.
enlarge y limits={abs=0.6pt, upper}
work?