Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

enter image description here

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.