Problem bei der Verwendung von atan in pgfplots

Problem bei der Verwendung von atan in pgfplots

Ich versuche, mit atan in pgfplots etwas darzustellen, aber das führt immer zu Hunderten von Fehlern.

Ich verwende ein Beispiel, das ich hier gefunden habe:

\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}

Die Fehler sind:

! 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))};

Und so geht es immer weiter. Über hundert Fehler und dann wird die Kompilierung ohne Ergebnis abgebrochen. Was mache ich hier falsch?

Antwort1

Laut Ihrer Protokolldatei haben Sie pgfplots1.11 und pgf2.10. Ich kann das Problem in dieser Kombination reproduzieren.

Es funktioniert mit beiden aktuellen Paketen (also pgfplots1.11 und pgf3.00).

Es funktioniert mit pgfplots1.10 und pgf2.10.

Lösungsalternativen für Sie sind:

  1. PGF auf 3.00 upgraden oder

  2. Downgrade von pgfplots auf 1.10 oder

  3. \addplot ... gnuplot {atan(x)};vorerst verwenden .

BEARBEITENEs stellt sich heraus, dass dieses Problem tatsächlich schlimmer ist als erwartet: Die Berichte inUndefinierte Steuersequenz: \pgfmath@multiply@thousandUndMiktex 2.9 pgfplots, Kollisionsproblem mit der Circuitikz-Bibliothekscheinen die gleiche Grundursache zu haben.

Die Grundursache liegt darin, dass pgfplotsVersuche, die alte PGF-Version zu patchen, das Patchen jedoch nicht angewendet werden kann (d. h. es handelt sich um einen Fehler in pgfplots).

Um dieses Problem zu umgehen, können Sie nach Möglichkeit (1) oder (2) vorgehen. Oder Sie fügen die Zeilen

% 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}%
}{}%

Vorwird geladen pgfplots. In diesem Fall wird davon ausgegangen, dass alles auf dem neuesten Stand ist und es wird nicht versucht, den defekten Patch anzuwenden. Risiko bei der Anwendung dieses Patches: Die trig format plotsin pgfplots1.11 eingeführte Funktion wird nicht funktionieren. Aber irgendwann wird sie funktionieren (wahrscheinlich mit der Version, die nach PGF 3.0.0 kommt).

verwandte Informationen