I want to create a bar graph using data from a table. Tikz automatically groups my data, but I need a different group size. The code that I wrote creates the following output:
But I want groups of size 3. Something like:
Here is my code:
\documentclass[border=1pt]{standalone}
\usepackage{pgfplots, pgfplotstable}
\pgfplotsset{width=10cm, height=5cm, compat=1.8}
\begin{document}
\begin{tikzpicture}
\pgfplotstableread{
X Contention alpha Name Test1 Test2 Test3 Test4
1 0 0.01 DT 7 49 24 0
2 0 0.50 DT 6 37 54 2
3 0 0.99 DT 7 42 48 4
4 100 0.01 DT 7 49 24 0
6 100 0.50 DT 7 42 46 4
7 100 0.99 DT 8 46 54 2
8 0 0.01 EU 22 50 8 0
9 0 0.50 EU 16 65 30 1
11 0 0.99 EU 16 69 26 2
12 100 0.01 EU 28 46 6 0
13 100 0.50 EU 16 69 31 0
14 100 0.99 EU 17 68 40 3
}\datatable
\begin{axis}[
ybar stacked,
bar width=8pt,
legend style={at={(0.2,0.9)},
anchor=north},
legend cell align={left}, % The command for legend alignment
xtick=data,
xticklabels from table={\datatable}{alpha},
xticklabel style={rotate=75,xshift=0ex,anchor=mid east},
]
\addplot table [x=X, y=Test1] {\datatable};
\addplot table [x=X, y=Test2] {\datatable};
\addplot table [x=X, y=Test3] {\datatable};
\addplot table [x=X, y=Test4] {\datatable};
\end{axis}
\end{tikzpicture}
\end{document}