I have a simple grouped bar chart but would like to have all group bars the same color. Currently each bar in a group is colored, possibly because of the way I have used addplot. I've tried to use a pgfplotsset list but this still changes each bar color, rather than the group. What I am after is all bars in black to be a single color, all in brown a single color, etc. Any suggestions welcomed!
![\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pagestyle{empty}
\begin{document}
\pgfplotsset{
/pgfplots/bar cycle list/.style={/pgfplots/cycle list={%
{blue,fill=blue,mark=none},%
{red,fill=red,mark=none},%
{brown!60!black,fill=brown!30!white,mark=none},%
{black,fill=gray,mark=none},
{fill=orange},
{fill=green},
{fill=olive},%
}
},
}
\begin{tikzpicture}
\begin{axis}\[
ybar=1pt,
bar width=6pt,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={TWh},
symbolic x coords={black,brown,gas,hydro,other},
nodes near coords align={vertical},
\]
\addplot coordinates {(black,118.4) (brown,56.3) (gas,17.5) (hydro,11.5) (other,4.3 )};
\addplot coordinates {(black,112.9) (brown,56.4) (gas,23.4) (hydro,13.4) (other,5.0)};
\addplot coordinates {(black,107.4) (brown,54.3) (gas,23.2) (hydro,14.7) (other,6.4)};
\addplot coordinates {(black,103.4) (brown,52.9) (gas,23.9) (hydro,14.6) (other,7.1)};
\addplot coordinates {(black,99.7) (brown,47.7) (gas,23.6) (hydro,16.9) (other,8.5)};
\legend{black, brown, gas, hydro, other}
\end{axis}
\end{tikzpicture}
\end{document}]
Best Answer
Here is a suggestion using a table. Each group gets its own column. Then the table is ploted column by column that means group by group.
It is also possible to plot only selected columns/groups: