当我尝试编译下面的 MWE 时抛出了以下错误:
Package pgfkeys Error: I do not know the key '/tikz/error' and I am going to ignore it.
Perhaps you misspelled it.
我正在运行带有最新发行版的 MacTeX 2012。
梅威瑟:
\documentclass[11pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0,
xmax = 30,
ymin = 0,
ymax = 0.45
]
\addplot[
color = black,
only marks,
error bars/.cd,
y dir = both,
y explicit,
] table[
y = set1,
error = stdev% comment out for MWE
] {
mcg set1 set2 set3 stdev
0 0.0000 0.0000 0.0000 0.0000
5 0.1031 0.0922 0.0819 0.01
10 0.1935 0.2137 0.2132 0.01
15 0.2875 0.2926 0.2888 0.003
20 0.3373 0.3394 0.3462 0.005
30 0.4396 0.4328 0.4362 0.003
};
\addplot[
color = red,
domain = 0:30
] {-0.0003*x^2 + 0.0224*x - 0.001};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您正在寻找下列键之一:
y error
需要一个列名(此处stdev
:),y error index
需要列索引,或者y error expr
期望一个表达式。
我还添加了mark options={mark size=.75}
以获得更好的视觉输出。默认大小对于这些错误来说看起来太大了。
代码
\documentclass[11pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin = 0,
xmax = 30,
ymin = 0,
ymax = 0.45
]
\addplot[
color = black,
only marks,
mark options={mark size=.75},
error bars/.cd,
y dir = both,
y explicit,
] table[
y = set1,
y error = stdev
] {
mcg set1 set2 set3 stdev
0 0.0000 0.0000 0.0000 0.0000
5 0.1031 0.0922 0.0819 0.01
10 0.1935 0.2137 0.2132 0.01
15 0.2875 0.2926 0.2888 0.003
20 0.3373 0.3394 0.3462 0.005
30 0.4396 0.4328 0.4362 0.003
};
\addplot[
color = red,
domain = 0:30
] {-0.0003*x^2 + 0.0224*x - 0.001};
\end{axis}
\end{tikzpicture}
\end{document}