This question already has an answer here:

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.

\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));


marked as duplicate by Phelype Oleinik, user156344, CarLaTeX, user121799, Raaja Apr 16 at 4:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    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. – user121799 Apr 16 at 1:07
  • Thanks for the help, I figured it out. I needed to put {rad(atan(\x))}. – user185895 Apr 16 at 1:16
  • Don't forget to set up a clipping rectangle, since atan goes to \pm\infnty at certain angles. – John Kormylo Apr 16 at 3:17
  • 1
    I'm voting to close this question as off-topic because it has solved in the comments. The answer(s) to the proposed duplicate question answers IMHO only 50% of the question. – user121799 Apr 16 at 3:27

Browse other questions tagged or ask your own question.