Is it possible to reverse the order of a cycle list
in pgfplots
, and if so, how can I do it?
I am using the pgfplots
library colorbrewer
to color a graph with four plots on it. I selected the palette OrRd
because it is has a four-color palette that the colorbrewer
website indicates is colorblind and photocopy safe. The palette includes a very light color that is hard to see against the white background of the plot. I would like to use the four darkest colors from the five or six color OrRd
palettes, but if I set one of those palettes as the active cycle list, they use the lighter colors first. I would like to issue a command to reverse the order of the cycle list so that the first plot uses the darkest colors and then later plots use lighter colors.
Here is a minimal working example (adapted from Stefan Pinnow's answer below):
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}
\pgfplotsset{
compat=1.16, cycle list/OrRd-6,}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
samples=2,
]
\foreach \i in {1,...,4} {
\addplot+ [very thick] {\i};
}
\end{axis}
\end{tikzpicture}
\end{document}
Here is the output of the above code: pgfplots follows the cycle list order and plots lines with lighter colors first and then darker colors. In this case, the lightest four colors of OrRd-6
are used.
Following is the output I desire: pgfplots follows the cycle list in reverse order. It plots using the darkest colors first, and then uses lighter colors.