Since I have multiple plots with error bars, I would like to shift the error bars slightly to make the overall plot more readable. However, when I try to do this using the variable of a \foreach as the amount to shift, I get an "undefined control sequence" error.
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\foreach \x/\y in {a/-1cm, b/0cm, c/1cm} {
\addplot+ [
%every error bar/.append style={xshift=\y},
%every node/.style={xshift=\y},
error bars/y dir=both,
error bars/y explicit,
] coordinates {
(0, 0) +- (0, 1)
(1, 0) +- (0, 1)
(2, 0) +- (0, 1)
};
}
\end{axis}
\end{tikzpicture}
\end{document}
(The document does not compile when I uncomment either one of the two comments.)
What's wrong here?
EDIT: Added another variable to the \foreach. In my actual use-case it would contain the filename to plot data from or the label to use for the curve.
\pgfplotsforeachungroupedinstead of\foreach– percusse Aug 30 '12 at 13:24\pgfplotsinvokeforeach, otherwise all the bars are moved by the distance specified last in the list. – Jake Aug 30 '12 at 13:25every nodestyle you're trying to move the plot markers? In that case, you'll have to useevery mark/.style. – Jake Aug 30 '12 at 13:26every error baris not the way to go for such use. ... Oops didn't see your comment. – percusse Aug 30 '12 at 13:30\pgfplotsforeachungrouped/\pgfplotsinvokeforeachdon't support multiple variables :-( (In my use-case I plot data from different files in each iteration of the loop). Also, why do you guys add comments instead of answers? – Vegard Aug 30 '12 at 13:32