# Unable to plot both axes and arccos function in pgfplots

What I want to plot is 3 functions: x=0, y=0, and x=cos^{-1}(x).

The plot and graph of the first two look like this:

\begin{center}
\begin{tikzpicture}
\begin{axis}[domain = -1:1, samples = 500, grid = both]
\addlegendentry{$x=0$}
\addlegendentry{$y=0$}
\end{axis}

\end{tikzpicture}
\end{center}


\begin{center}
\begin{tikzpicture}
\begin{axis}[domain = -1:1, samples = 500, grid = both]
\addlegendentry{$x=0$}
\addlegendentry{$y=0$}
\addlegendentry{$\cos^{-1}(x)$}
\end{axis}

\end{tikzpicture}
\end{center}


Everything gets messed up. Why is this?

-

The horizontal domain gives the impression that nothing has changed but because you have suddenly increased the vertical axis to 150 domain=-1:1 becomes invisible.

Also you are using 500 samples to constant plots. Supply individually instead, here is with 130

  \begin{tikzpicture}
\begin{axis}[grid = both,samples=2]
\addlegendentry{$x=0$}
\addlegendentry{$y=0$}
\addplot[draw = blue,samples = 101,domain = -1:1] {acos(x)};
\addlegendentry{$\cos^{-1}(x)$}
\end{axis}

\end{tikzpicture}


-
That makes a lot of sense! It didn't occur to me that this was the issue because in my mind domain was the opposite direction. And thank you for the suggestion about the samples! – Abe Fehr Mar 6 at 13:17
@AbeFehr My pleasure – percusse Mar 6 at 13:54

As it turns out, pgfplots (and the underlying PGF, I think) treat the input to trigonometric functions as degrees, not radians. You can force it to be in radians by the key trig format=rad. This also fixes your y-domain issues:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain = -1:1, samples = 500, grid = both]
\addlegendentry{$x=0$}
\addlegendentry{$y=0$}
\addlegendentry{$\cos^{-1}(x)$}