1

I'm trying to get pgfplots working with the colorbrewer library. So far, the example in the accepted answer here works for me, but as soon as I add options to the \addplot command, the colors are gone and all plots are drawn in black.

MWE: The following document produces black plots, and removing the [const plot] option fixes this, but I really do need to specify this and other options.

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

\begin{document}

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

\end{axis}
\end{tikzpicture}

\end{document} 

Is this a known issue with workarounds etc. or am I doing somethig wrong?

1 Answers1

3

Either move const plot to the axis options or replace \addplot [...] by \addplot+ [...]. The latter is needed, because otherwise only the given optional arguments are used. The difference to the + is, that then the optional arguments are appended.

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{colorbrewer}
\begin{document}

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

image showing the result of above code

Stefan Pinnow
  • 29,535