TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to plot a function with pgfplots for LaTeX. Unfortunately, pgfplots plots the function incorrectly. Here is the LaTeX code I use:

        {0.5 + 0.5 * ((atan(x) * 2 / pi)^11.79)};
\caption{Omzetten van aantal gameplays tot impliciete rating}

Here is how the function should look like:

This is how it is plotted:

Does anyone know what I do wrong?

Thanks in advance!

share|improve this question
Hi @Jan, welcome to tex.sx. Note that you original question was now migrated to this site. You might want to connect your stackoverflow.com account with your tex.sx account. You can do at your user page. I'm closing the other one for now. – Martin Scharrer Mar 8 '11 at 13:44
up vote 12 down vote accepted

TikZ uses degrees instead of radians (yes, yes, I know ...). So you need to replace pi by 180 (or, as Jake suggests in the comments, replace atan(x) by rad(atan(x)); the rad function converts degrees to radians).




        {0.5 + 0.5 * ((atan(x) * 2 / 180)^11.79)};

This produces:

PGFPlots with degrees

which looks a lot more like what you want (the numbers on your graph are a little small for me so I compared with the output I get from gnuplot using your function and it looks right when compared with that).

share|improve this answer
@Andrew: I don't know pgfplots very well but it's possible to use gnuplot with pgfplots, no? – Alain Matthes Mar 8 '11 at 14:08
Or you can replace atan(x) with rad(atan(x)), which might be useful if you have more complicated functions and don't want to change all the coefficients. – Jake Mar 8 '11 at 14:09
@Altermundus: Nor do I! But I've run into the radians/degrees issue with TikZ often enough that it was the first thing I thought of when I saw atan and it seemed to fix it. – Loop Space Mar 8 '11 at 14:13
@Jake: Yes, good point. I'll edit that in as an alternative. – Loop Space Mar 8 '11 at 14:13
@Jan you might want to accept this answer, since it directly addressed your problem. – Alan Munn Mar 8 '11 at 14:54

This is old but I found it when I had the same problem. Now there is a new solution called trig format plots=rad.

\begin{axis}[trig format plots=rad]

See the manual section 4.3.3 Computing Coordinates with Mathematical Expressions.

Just for search engines: pgfplots, trigonometric functions, radian, degree, wrong result, wrong plot

share|improve this answer
I just searched pgfplots wrong plot – bosonix Aug 28 '14 at 13:52
Haha - cool coincidence :) – Dr. Manuel Kuehner Aug 28 '14 at 14:00

Only for information. This is not an answer but I try your function with tkz-fct (tkz-fct works with tikz and gnuplot).

pgfplots is more complete and sophisticated package than tkz-fct.



        \tkzFct[domain=1:30]{0.5 + 0.5 * ((atan(\x) * 2 / pi)**11.79) }



enter image description here

share|improve this answer

Your Answer


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.