# Selecting colors which are evenly spaced around a color wheel

In the following diagram

I would like to assign colors to the rectangles in each layer with colors from around a color wheel so that the colors in adjacent layers are separated by 144 degrees. For context $b_{1}b_{2}b_{3}b_{4}b_{5}$ is a string of elements from a Boolean algebra. The horizontal position indicates the "location" of the element. Here is the code

\documentclass[paper=letter,fontsize=12pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{mathtools}
\begin{document}
\begin{tikzpicture}
\node (b1)  at (-1.0, 0.25) {$b_{1}$};
\node (b2)  at  (-1.0, 0.75) {$b_{2}$};
\node (b3)  at (-1.0, 1.25) {$b_{3}$};
\node (b4)  at  (-1.0, 1.75) {$b_{4}$};
\node (b5)  at (-1.0, 2.25) {$b_{5}$};
\draw (0, 0) -- ( 3.5, 0);
\fill[blue!50!white]    (0, 0) rectangle (1.0, 0.5);
\fill[green!50!white]   (1.5, 0.5) rectangle (2.5, 1.0);
\fill[red!50!white]     (0.75, 1.0) rectangle (1.75, 1.5);
\fill[red!50!white]     (3.0, 1.0) rectangle (3.5, 1.5);
\fill[purple!50!white]    (0.75, 1.5) rectangle (1.5, 2.0);
\fill[yellow!50!white]   (0.75, 2.0) rectangle (1.5, 2.5);
\end{document}


If there is a better method for accomplishing this task, feel free to mention it.

• Maybe have a look at the package ninecolors? You could also use the hsb model from the xcolor package and for each step increase the hue by, for example 10 degrees. Aug 6 at 1:22

You can use the hsb color model and increase the hue by 144 degrees for each row. But you need to load the xcolor package with the rgb option before loading the tikz package on order to make this work.

\documentclass[border=10pt]{standalone}
\usepackage[rgb]{xcolor}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\foreach \i in {1,...,10} {
\pgfmathparse{mod(\i*144,360)}
\definecolor{current}{Hsb}{\pgfmathresult,.5,1}
\node[fill=current, inner sep=10pt] at (\i, 0) {};
}

\end{tikzpicture}
\end{document}


The same than Jasper bur on a weel:

\documentclass[border=10pt]{standalone}
\usepackage[rgb]{xcolor}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[dotted] (0,0) circle(2);
\foreach \i in {1,...,10} {
\pgfmathparse{mod(\i*144,360)}
\definecolor{current}{Hsb}{\pgfmathresult,.5,1}
\node[fill=current, inner sep=6pt] at (\i*36:2) () {};
}

\end{tikzpicture}
\end{document}


The output:

• Thank you for showing how to put items in a circle. The diagrams I need are more like the diagram in my question.
– Jay
Aug 7 at 12:47