# How to define a custom pgf color palette from a given base color?

I have a stacked plot with seven plots, and I'm trying to obtain a set of colors that suit with the primary color of the rest of the document.

The code is the following:

\documentclass{article}

\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}

\definecolor{myblue}{RGB}{95,145,166}

\begin{document}

\tikz \path node[rectangle, fill=myblue,inner sep=1cm] {};

\begin{tikzpicture}

\begin{axis}[
xbar stacked,
cycle list/Blues-7, cycle list name=Blues-7,
every axis plot/.style={fill}
]

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};
\end{axis}
\end{tikzpicture}

\end{document}


And its output is:

So the Blue-7 cycle list from color brewer is the closest that I could find, but the tonality is different and thus wrong.

Is there a way to obtain a 7-color cycle list similar to the XX-7 ones from colorbrewer but based on my basic blue color shown above? Looking at it, the base color may probably be the darkest of the series.

I'm citing specifically color brewer because the luminosity difference between different color in the original Blue-7 palette sounds quite right. Anyway, I don't need the colors to be necessarily automatically computed.

You can always define your own things.

\documentclass{article}

\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}

\definecolor{myblue}{RGB}{95,145,166}

\begin{document}

\tikz \path node[rectangle, fill=myblue,inner sep=1cm] {};
\pgfplotscreateplotcyclelist{my blues}{%
myblue,myblue!90,myblue!80,myblue!70,myblue!60,myblue!50,myblue!40,myblue!30,myblue!20}
\begin{tikzpicture}

\begin{axis}[
xbar stacked,
cycle list name=my blues,
every axis plot/.style={fill},
]

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

first second
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};

prova colonna
1     5
2     6
3     7
4     8
};
\end{axis}
\end{tikzpicture}

\end{document}


Of course, you could also define the list in a loop (but here copy & paste was even faster ;-).

• Thanks, but 1) why calling the Blues-7 key anyway? And 2) can I give a name to the list? – gigabytes Nov 6 '18 at 14:53
• @gigabytes as for 1) good catch! and as for 2) sure, see my update. – user121799 Nov 6 '18 at 15:04