I'm using scatter/classes
to define color and markers for a plot, and I would like to specify the error bar color this way as well (to match the marker color). I have seen the error bar colors in scatter plot post, but I don't know how to use the scatter class color, rather than the mapped color. Specifying the error bar color in the scatter/classes
does not work.
\documentclass[article]{standalone}
\usepackage{graphicx}
\usepackage{pgf,tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot [scatter,
only marks,
scatter src=explicit symbolic,
scatter/classes={
A0={mark=o,red,/pgfplots/error bars/.cd,
error mark options={draw=red}},
A1={mark=square,blue}},
error bars/.cd,
y dir=both,
y explicit]
table[x=x,y=y,y error=err,meta=class,row sep=crcr] {
x y err class\\
0 0 1 A0\\
1 1 1 A0\\
2 0 1 A1\\
3 2 2 A1\\
};
\end{axis}
\end{tikzpicture}
\end{document}
every mark
andmark options
have no effect when used inside of <styles for each class name>! So, instead of assigningmark options
, you can simply provide the options directly. They apply only to markers anyway."