# pgfplots: wrong domain, wrong axis, uncentered graph… is it a bug?

## Question

I get a very strange graph with pgfplots, see the picture below.

What is going wrong?

## Code and picture

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

\begin{tikzpicture}
\begin{axis}[
axis x line = middle,
axis y line = middle,
xmin = -1,
xmax = 1,
grid = major,
clip = false]
\addplot[color=orange, smooth, ultra thick] {sin(deg(x))} node[right] {$\sin$};
\end{axis}
\end{tikzpicture}

\end{document}


-
clip=true solve this. –  ferahfeza Apr 7 '14 at 11:48
Thanks! But, what if I want clip=false, for other reasons? (see my updated code, with the label "sin" next to to the curve). –  Colas Apr 7 '14 at 11:56

If you use clip=false you turn off the clever trimming mechanism of pgfplots. By default, the domain is larger than -1:1 hence you get the extra drawing (I think it's -6:6 it's -5:5 by default). So you have to adjust the domain too.

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

\begin{tikzpicture}
\begin{axis}[
axis x line = middle,
axis y line = middle,
xmin = -1,
xmax = 1,
grid = major,
domain=-1:1,
clip = false]

Default is -5:5 FYI; otherwise a great explanation! :-) –  Paul Gessler Apr 7 '14 at 12:04