3

I'm trying to plot something using atan in pgfplots, but it always results in hundreds of errors.

I'm using an example I found here:

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

\pgfplotsset{compat=1.9}
\begin{tikzpicture}
\begin{axis}[
     width=160pt,compat=1.5.1,grid style={ultra thin},every axis plot post/.append style={thick},
     x tick label style={font=\tiny},y tick label style={font=\tiny},
     scale only axis,grid=major,axis lines=middle,
     xlabel={$x$},
     ylabel={$y$},
     xmin=-200,
     xmax=200,
     domain=-200:210,
     ymin=-5.5,
     ymax=5.5,
     xtick={-150,-100,...,150},
     ytick={-5, -4,...,5},
     restrict y to domain=-20:20,
     legend style={at={(0.5,-0.05)},anchor=north,nodes={right}},
 ]
 \addplot[mark=none,color=blue, samples=500]{rad(atan(x))};
 \addlegendentry{$y = \tan^{-1}x $};
 \end{axis}
\end{tikzpicture}

\end{document}

The errors are:

! Undefined control sequence.
<recently read> \pgfmath@multiply@thousand 

l.23 ...ne,color=blue, samples=500]{rad(atan(x))};

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\pgfmath@basic@atan@ ... pt \pgfmath@table@lookup 
                                                  {\pgfmath@x }{pgfmath@atan...
l.23 ...ne,color=blue, samples=500]{rad(atan(x))};

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing number, treated as zero.
<to be read again> 
                   }
l.23 ...ne,color=blue, samples=500]{rad(atan(x))};

And it goes on and on. Over hundred errors and then it stops compiling with no result at all. What am I doing wrong here?

  • It runs fine with pgfplots 1.8 -- Package: pgfplots 2013/03/17 v1.8 Data Visualization (1.8-3-gaf58a29) – Jesse Dec 14 '14 at 14:08
  • I don't have any problem either. You have conflicting compat keys and it should be outside the axis environment. I think you have an outdated version. Put \pgfplotsversion somewhere after the \begin{document} to see what it is. Latest version is 1.11 – percusse Dec 14 '14 at 14:11
  • Hm, i also have version 1.11 installed. I put the full log here: http://pastebin.com/UirsSrwm

    Maybe someone can find the problem.

    – ElBartoME Dec 14 '14 at 14:19

1 Answers1

6

According to your log file, you have pgfplots 1.11 and pgf 2.10 . I can reproduce the problem in this combination.

It works with both packages up to date (i.e. pgfplots 1.11 and pgf 3.00).

It works with pgfplots 1.10 and pgf 2.10.

Solutions alternatives for you are:

  1. upgrade PGF to 3.00 or

  2. downgrade pgfplots to 1.10 or

  3. use \addplot ... gnuplot {atan(x)}; for the time being.

EDIT It turns out that this problem is actually worse than anticipated: the reports in Undefined control sequence: \pgfmath@multiply@thousand and Miktex 2.9 pgfplots, circuitikz library collision problem appear to have the same root cause.

The root cause is that pgfplots attempts to patch the old PGF version; but that patch fails to apply (i.e. it is a bug in pgfplots).

To workaround it, you can proceed according to option (1) or (2). Or you can add the lines

% HACK: deactivate feature 'trig format' but restore compatibility
% between pgfplots 1.11 and tikz 2.10:
\csname pgfutil@ifundefined\endcsname{pgfmathiftrigonometricusesdeg}{%
    \def\pgfmathiftrigonometricusesdeg#1#2{#1}%
}{}%

before loading pgfplots. In this case, it will assume that everything is up-to-date and will not attempt to apply the broken patch. Risk of applying this patch: the feature trig format plots introduced in pgfplots 1.11 will not work. But it will eventually (probably with the version which will come after PGF 3.0.0).