# Fill pgfplot bars with colorbrewer

I want to use colorbrewer in my project since it provides color cycle lists but I struggle to use them in the right way I think. Please have a look at my MWE:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{cycle list/Dark2-8}

\begin{document}

\begin{figure}[h!]
abc & 1 \\
def & 5 \\
}\datapoints
\begin{tikzpicture}
\begin{axis}[
% general appearance
ybar,
cycle multi list=Dark2-8,
% x axis
symbolic x coords={def},
xtick=data,
xticklabel style={align=center},
% y axis
bar width=0.2cm,
% legend
area legend,
legend entries={1},
legend pos=north west
]
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}


My Problem is, that the bar is not filled and I don't really know how to achieve this without adding a manual fill for each addplot.

By the way, if I try to add fill=Dark2-8-1 to the addplot options I get the error ! Package xcolor Error: Undefined color Dark2-8-1.

Can anybody point out where I went wrong?

You can add every axis plot/.append style={fill} to solve the fill problem. Also, you can call a specific color from the cycle list by using Dark2-<color letter>, if the cycle list initialized is Dark2-8 a color from the list is Dark2-D.

## Code

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{cycle list/Dark2-8}

\begin{document}
x   y
a   5
b   6
c   4
}\mytable

\begin{tikzpicture}
\begin{axis}[
ybar,
symbolic x coords={a,b,c},
xtick=data,
every axis plot/.append style={fill},
cycle list name=Dark2-8
]
\end{axis}
\end{tikzpicture}
\end{document}


Another way, recommended by the PGFPlots manual, to get a particular color from an initialized color scheme, is by using the key index of colormap as follows:

\addplot[index of colormap=3 of Dark2-8] coordinates {(a,7) (b,1) (c,2)};


## Result

• Is there a reference that lists the Dark2-D name scheme? I only found Dark2-8-1. – Rambo Ramon Jul 4 '16 at 22:26
• In the section 5.2.4 of PGFPlots manual (v1.13) you can see that a reference to a particular color within every qualitative scheme is made with a letter. Then Dark2-D is not a scheme name by itself, but a particular color within the Dark2-<set> scheme initialized. – osjerick Jul 4 '16 at 22:37