# pgfplots: the margins “eat” some parts of my graph

## Question

I use pgfplots with the ultra thick option ans without explicitly giving the domain for the y-axis.

It seems that in this case, some part of my graph is "eaten" by the margin: see the picture below to understand what I mean.

Is there a way to avoid this?

## Code

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\pgfplotsset{every axis/.append style={
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style={->},  % arrows on the axis
xlabel={$x$},          % default put x on x-axis
ylabel={$y$},          % default put y on y-axis
grid = major
}}

\begin{axis}[xmin=-5,xmax=5]
\addplot[orange,smooth, ultra thick] {sin(deg(x))} ;
\end{axis}
\end{tikzpicture}

\end{document}

-

The reason is that everything outside the axis is clipped, and with thick lines at the edge of the edge, part of them is chopped off (similar to Node only partially rendered near edge of plot). You could add clip=false to turn off clipping, or extend the y axis a little bit, e.g. with enlarge y limits={rel=0.01}.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\pgfplotsset{every axis/.append style={
axis x line=middle,    % put the x axis in the middle
axis y line=middle,    % put the y axis in the middle
axis line style={->},  % arrows on the axis
xlabel={$x$},          % default put x on x-axis
ylabel={$y$},          % default put y on y-axis
grid = major,
enlarge y limits={rel=0.01}
%clip=false
}}

\begin{axis}[xmin=-5,xmax=5]
\addplot[orange,smooth, ultra thick] {sin(deg(x))} ;
\end{axis}
\end{tikzpicture}

\end{document}
-