4

I would like to use colorbrewer with pgfplots to nicely color some graphs in my document. However, this minimal working example given in the answer to another question

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}   
\usepgfplotslibrary{colorbrewer}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    colorbrewer cycle list=Dark2,
]
\addplot {rnd};
\addplot {rnd-1};
\addplot {rnd-2};
\addplot {rnd-3};

\end{axis}
\end{tikzpicture}

\end{document}  

throws this error:

./Plots.tex:47: Package pgfkeys Error: I do not know the key '/tikz/colorbrewer cycle list', to which you passed 'Dark2', and I am going to ignore it. Perhaps you misspelled it.

I assume the error comes from an incorrect installation of the relevant files from Github. I am currently using MacOS.

I followed the installation steps and copied all files to a folder I created in

/usr/local/texlive/texmf-local/tex/latex/colorbrewer

and ran the texhash command - to no avail.

Why can't I get nice colors in my pgfplot plots? Am I at least correct in assuming that the installation is the cause of my troubles, or is the library already included in the colorbrewer package?

7

You shouldn't have to install the library separately, it is included with pgfplots. But you should use cycle list/Dark2, not colorbrewer cycle list=Dark2.

Output with ultra thick:

enter image description here

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}   
\usepgfplotslibrary{colorbrewer}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
    cycle list/Dark2,
]
\addplot {rnd};
\addplot {rnd-1};
\addplot {rnd-2};
\addplot {rnd-3};

\end{axis}
\end{tikzpicture}

\end{document} 
|improve this answer|||||
  • 2
    Still gives me the error: "I do not know the key '/tikz/cycle list/Dark2'". Just found out, that it works if I use "cycle list name=Dark-2". – Wasserwaage Apr 8 '18 at 19:04
3

You first have to load the colormap/cycle list which is done by colormap/<colormap name/cycle list/<cycle list name>.

% used PGFPlots v1.15
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{colorbrewer}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        % activates the `cycle list', i.e. it is initialized and selected
        % (this will also initialize the associated `colormap', but doesn't
        %  select it)
        cycle list/Dark2,
    ]
        \addplot {rnd};
        \addplot {rnd-1};
        \addplot {rnd-2};
        \addplot {rnd-3};
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.