# How do I plot the graph of arctan using Tikz, NOT using pgfplots [duplicate]

I am trying to plot the atan() function, but it keeps giving me an error. This is my code. What in the world am I doing wrong? Why doesn't it plot on the graph I made. Also I cannot use pgfplots.

\begin{tikzpicture}
\draw [help lines] (-5,-pi) grid (5,pi);
\draw [->,thick] (-5,0) -- (0,0) -- (5,0) node [below] {\small $x$};
\draw [->,thick] (0,-pi) -- (0,pi) node [left] {\small $y$};
\foreach \x in {-5,-4,...,5} \draw (\x, -0.1) -- (\x,0.1);
\foreach \x in {-5,-4,...,-1} \node at (\x, -0.1) [below] {\tiny $\x$};
\foreach \x in {1,2,...,5} \node at (\x, -0.1) [below] {\tiny $\x$};

\draw (-0.1, -pi/2) -- (0.1,-pi/2);
\draw (-0.1, -pi/4) -- (0.1,-pi/4);
\draw (-0.1, pi/4) -- (0.1,pi/4);
\draw (-0.1, pi/2) -- (0.1,pi/2);

\node at (-0.1, -pi/2) [left] {\tiny $-\pi/2$};
\node at (-0.1, -pi/4) [left] {\tiny $-\pi/4$};
\node at (-0.1, pi/4) [left] {\tiny $\pi/4$};
\node at (-0.1, pi/2) [left] {\tiny $\pi/2$};

\draw [scale=0.5,domain=0:5,variable=\x] plot (\x,atan(\x r));

\end{tikzpicture}


## marked as duplicate by Phelype Oleinik, JouleV, CarLaTeX, marmot, RaajaApr 16 at 4:01

• Enclose atan(\x r) in braces: plot (\x,{atan(\x r)}); – Phelype Oleinik Apr 16 at 1:03
• Try \draw[blue] plot[domain=0:5,variable=\x,samples=71] (\x,{atan(\x r)*pi/180});, i.e. scale the plot to radians. – marmot Apr 16 at 1:07