I would like to create grouped bar plots using pgfplots
. The result I would like to have is similar to the figures below, but one on top of the other instead of next to each other.
I tried the following code, but it's not giving me what I am looking for:
\begin{figure}
\centering
\pgfplotstableread{
0 0 0.2857 0 0 0 0.4286 0 0
1 0.7143 0.8571 0.7143 0 0.7143 0.8571 0.7143 0
2 0.7143 0.2857 0.5714 0.1429 0.7143 0.2857 0.5714 0.1429
3 0 0 0 0.8571 0 0 0 0.8571
}\first
\pgfplotstableread{
0 0 0.1429 0 0 0 0.1429 0 0
1 0 0.2857 0 0 0 0.4286 0 0
2 0 0.7143 0 0 0 0.7143 0 0
3 1.0000 0.2857 1.0000 0.1429 1.0000 0.2857 1.0000 0.1429
4 0 0 0 0.8571 0 0 0 0.8571
}\second
\begin{tikzpicture}
\begin{groupplot}[
group style={group size = 1 by 2, xticklabels at=edge bottom},
ymin=0,
axis on top,
ybar=1pt,
xtick=data,
enlarge x limits=0.2,
every axis plot/.append style={fill},
cycle list name = Paired,
tick label style={font=\footnotesize},
width = 0.8\textwidth
]
\nextgroupplot
\addplot[] table[x index=0,y index=0] \first;
\addplot[] table[x index=0,y index=1] \first;
\addplot[] table[x index=0,y index=2] \first;
\addplot[] table[x index=0,y index=3] \first;
\addplot[] table[x index=0,y index=4] \first;
\addplot[] table[x index=0,y index=5] \first;
\addplot[] table[x index=0,y index=6] \first;
\addplot[] table[x index=0,y index=7] \first;
%\coordinate (top) at (rel axis cs:0,1);
\nextgroupplot
\addplot[] table[x index=0,y index=0] \second;
\addplot[] table[x index=0,y index=1] \second;
\addplot[] table[x index=0,y index=2] \second;
\addplot[] table[x index=0,y index=3] \second;
\addplot[] table[x index=0,y index=4] \second;
\addplot[] table[x index=0,y index=5] \second;
\addplot[] table[x index=0,y index=6] \second;
\addplot[] table[x index=0,y index=7] \second;
%\coordinate (bot) at (rel axis cs:1,0);
\end{groupplot}
%\path (top-|current bounding box.west)--node[anchor=south,rotate=90] {Empirical prob. of correctly selecting the order} (bot-|current bounding box.west);
%%Legend
%\path (top|-current bounding box.north)--coordinate(legendpos) (bot|-current bounding box.north);
%\matrix[ matrix of nodes, anchor=south, draw, inner sep=0.2em, draw]
%at([yshift=1ex, xshift=-7.5ex]legendpos)
% {
% \ref{SBC}&SBC&[5pt]
% \ref{FPE}&FPE&[5pt]
% \ref{RNML}&RNML&[5pt]
% \ref{AIC}&AIC&[5pt]
% \ref{AICc}&$\mathrm{AIC_{c}}$&[5pt]
% \ref{KIC}&KIC&[5pt]
% \ref{KICc}&KIC&[5pt]
% \ref{KICd}&$\mathrm{KIC_{c}}$&\\};
\end{tikzpicture}
\caption{}
\label{}
\end{figure}