So here is the solution I managed to put up. I used the example from Jakes link and it solved the problem pretty much the way it should. Also, with using the table, I was able to use the same axis-label several times, so all is fine.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\newcounter{groupcount}
\pgfplotsset{
draw group line/.style n args={5}{
after end axis/.append code={
\setcounter{groupcount}{0}
\pgfplotstableforeachcolumnelement{#1}\of\datatable\as\cell{%
\def\temp{#2}
\ifx\temp\cell
\ifnum\thegroupcount=0
\stepcounter{groupcount}
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (startgroup) at (axis cs:\pgfplotsretval,0);
\else
\pgfplotstablegetelem{\pgfplotstablerow}{[index]0}\of\datatable
\coordinate [yshift=#4] (endgroup) at (axis cs:\pgfplotsretval,0);
\fi
\else
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
\fi
}
\ifnum\thegroupcount=1
\setcounter{groupcount}{0}
\draw [
shorten >=-#5,
shorten <=-#5
] (startgroup) -- node [anchor=north] {#3} (endgroup);
\fi
}
}
}
\pgfplotstableread{
1 15 4 1
2 13 3 1
3 18 5 2
4 10 1 2
}\datatable
\begin{document}
\makeatletter
\begin{tikzpicture}
\begin{axis}[
ylabel=label,
xtick=data,
xticklabels={x, y, x, y},
enlarge y limits=false,
enlarge x limits=0.1,
ymin=0,ymax=25,
ybar,
bar width=20pt,
legend style={
font=\footnotesize,
cells={anchor=west},
legend columns=5,
at={(0.5,-0.2)},
anchor=north,
/tikz/every even column/.append style={column sep=0.2cm}
},
draw group line={[index]3}{1}{a}{-3.5ex}{7pt},
draw group line={[index]3}{2}{b}{-3.5ex}{7pt},
]
\addplot+[error bars/.cd,y dir=both,y explicit] table[x index=0,y index=1,y error index=2] \datatable;
\end{axis}
\end{tikzpicture}
\end{document}
percusse, I do not have a working sample that draws without the second axis yet since I did not figure how I can add the same content to an axis multiple times. (i.e. I have a measurement at setting a x and at b x, yet I did not see how to get that to work since \xticklabels merges same entries into one.
– locutus Apr 29 '13 at 07:54\documentclass{...just to try out some ideas about a possible answer. That's usually called MWE(minimum workable example). Well the original MWE stands for working example but it doesn't have to be working to work on. – percusse Apr 29 '13 at 08:35