pgf 图上带有颜色的误差线

pgf 图上带有颜色的误差线

我试图将误差线的颜色设置为与 pgf-plot 上的数据相同的颜色。该方法之前已在此处进行了详细说明 -定义散点图类中的误差线颜色

我一开始的代码

\begin{figure}[htbp] 
\centering
\begin{tikzpicture} 
\begin{axis}[
xlabel={time, $s$},
ylabel={fraction},
ymin=0, ymax=1,
grid=major,
legend entries={$16nt$,$40nt$,$62nt$},
]
\addplot[
scatter,
only marks,
scatter src=explicit symbolic,
scatter/classes={
  16nt={mark=square*,blue},
  40nt={mark=triangle*,red},
  62nt={mark=*,draw=black}
  },
error bars/.cd,
y dir=both,
y explicit
]
table[x=x, y=y,y error = err, meta=label, row sep=crcr] {
x      y      err    label\\
0.1    0.15   0.1    16nt\\
0.45   0.27   0.1    16nt\\
0.02   0.17   0.1    16nt\\
0.06   0.1    0.1    16nt\\
0.9    0.5    0.1    40nt\\
0.5    0.3    0.1    40nt\\
0.85   0.52   0.1    40nt\\
0.12   0.05   0.1    40nt\\
0.73   0.45   0.1    62nt\\
0.53   0.25   0.1    62nt\\
0.76   0.5    0.1    62nt\\
0.55   0.32   0.1    62nt\\
};
\end{axis}
\end{tikzpicture}
\caption{trial plot}
\end{figure}

但当我改变

error bars/.cd,
y dir=both,
y explicit` by `error bars with color=err 

正如上述答案中所述,并添加

error bars with color/.style={
visualization depends on=\thisrow{#1} \as \error,
visualization depends on=y \as \y,
scatter/@pre marker code/.append code={ % Homebrew color bars
        \draw (0,0) -- +(axis direction cs:0,-\error) -- +(axis direction cs:0,\error);
        \draw (0,0) plot [mark=-] coordinates {(axis direction cs:0,\error) (axis direction cs:0,-\error)};
},
error bars/.cd, % Invisible color bars, to get the right axis limits
        y dir=both,
        y explicit,
        error bar style={opacity=0},
/pgfplots/.cd
}

我无法编译我的文档,因为它显示的错误符合 \end{axis}

带有消息

TeX 容量超出,抱歉[grouping levels=255]。\pgfmth@float@parse#1->\begingroup\pgfkeys{/pgf/fpu/pgf/fpu/output form... \end{axis}

这是什么意思?抱歉,这个问题很愚蠢,我是 LaTex 的新手,对此真的很了解!

相关内容