I want to plot average values of some measure as bar charts with error bars and its maximal values as marks above the bars.
I use two separate plots for that now. The problem is aligning marks with bars: right now all marks are positioned at the same symbolic-X position, whereas I want each mark to be above the corresponding bar (and have the same colour, but that's probably not that big a problem).
Here's a not-so-minimal example:
\documentclass{report}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
ymin=0, yticklabel style={/pgf/number format/fixed},
symbolic x coords={0,1,2,3}, enlarge x limits=0.15,
legend style={at={(0.5,-0.2)}, anchor=north, legend columns=-1},
]
\addplot+ [nodes near coords, point meta=explicit symbolic, error bars/.cd, y dir=both, y explicit]
table[x index=0, y index=1, y error index=2, meta index=3] {
0 0.1 0.0040 0
1 0.0358 0.0017 224
2 0.0358 0.0017 224
3 0.0358 0.0017 224
};
\addplot+ [nodes near coords, point meta=explicit symbolic, error bars/.cd, y dir=both, y explicit]
table[x index=0, y index=1, y error index=2, meta index=3] {
0 0.1 0.0041 0
1 0.0322 0.0016 224
2 0.0321 0.0014 252
3 0.0321 0.0014 266
};
\addplot+ [only marks] table[x index=0,y index=1] {
0 0.2
1 0.06
2 0.06
3 0.06
};
\addplot+ [only marks] table[x index=0,y index=1] {
0 0.15
1 0.04
2 0.04
3 0.04
};
\legend{P1,P2}
\end{axis}
\end{tikzpicture}
\end{document}

every mark/.append style={xshift=-6pt}to the first of the marker plots, andevery mark/.append style={xshift=6pt}to the second. The value of6ptis half the bar width (default value10pt) plus half the bar gap (default value2pt). – Jake Apr 25 '13 at 16:31\addplot+ [only marks,every mark/.append style={xshift=-12pt}]in your document leads to the marks being shifted too far to the left for me, but if it works for you, that's great – Jake Apr 26 '13 at 11:33[scale=0.6], which apparently affects the positioning.Without it suggested values 6/-6pt work as expected. Thanks a lot again!
– wxd Apr 26 '13 at 11:56