
我試圖在 pgfplots 中使用 atan 繪製一些內容,但它總是會導致數百個錯誤。
我正在使用在這裡找到的範例:
\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}
錯誤是:
! 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))};
這種情況一直持續下去。超過一百個錯誤,然後它停止編譯,根本沒有任何結果。我在這裡做錯了什麼?
答案1
根據您的日誌文件,您有pgfplots
1.11 和pgf
2.10 。我可以用這個組合重現這個問題。
它適用於兩個最新的軟體包(即pgfplots
1.11 和pgf
3.00)。
它適用於pgfplots
1.10 和pgf
2.10。
您的替代方案有:
將 PGF 升級到 3.00 或
將 pgfplots 降級到 1.10 或
\addplot ... gnuplot {atan(x)};
暫時使用。
編輯事實證明,這個問題實際上比預想的更嚴重:未定義的控制序列:\pgfmath@multiply@thousand和Miktex 2.9 pgfplots、Circuitikz庫碰撞問題似乎有相同的根本原因。
根本原因是pgfplots
試圖修補舊的PGF版本;但該補丁無法套用(即它是 中的錯誤pgfplots
)。
若要解決此問題,您可以按照選項 (1) 或 (2) 繼續操作。或者您可以新增行
% 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}%
}{}%
前載入中pgfplots
.在這種情況下,它將假設所有內容都是最新的,並且不會嘗試套用損壞的補丁。套用此補丁的風險:1.11trig format plots
中引入的功能pgfplots
將無法使用。但它最終會出現(可能是 PGF 3.0.0 之後的版本)。