For a visualization I have in mind I'd like to create an rectangular arrangement of filled circles using different colors. For example, something like this:
+ + + +
+ + + *
+ + * *
+ * * *
* * * *
Where the +
would be blue circles and the *
would be red circles.
I created a somewhat functional version of this adapted from some other question:
\documentclass[border=5pt,tikz,multi]{standalone}
\usetikzlibrary{fit,positioning}
\begin{document}
\begin{tikzpicture}[ultra thick]
\coordinate (c0) at (0,0);
\foreach \i [count=\j, evaluate=\j as \k using \j-1, evaluate=\j as \n using { \j>0 ? "blue" : "red" }] in {1,...,3}
\node (c\j) [right=5 pt of c\k |- c0, circle, anchor=north west, minimum size=1mm, draw, fill=\n, \n] {};
\coordinate (c0) at (0,1);
\foreach \i [count=\j, evaluate=\j as \k using \j-1, evaluate=\j as \n using { \j>1 ? "blue" : "red" }] in {1,...,3}
\node (c\j) [right=5pt of c\k |- c0, circle, anchor=north west, minimum size=1mm, draw, fill=\n, \n] {};
\coordinate (c0) at (0,2);
\foreach \i [count=\j, evaluate=\j as \k using \j-1, evaluate=\j as \n using { \j>2 ? "blue" : "red" }] in {1,...,3}
\node (c\j) [right=5pt of c\k |- c0, circle, anchor=north west, minimum size=1mm, draw, fill=\n, \n] {};
\end{tikzpicture}
\end{document}
Which renders like this:
I have a few problems with that:
- I can't find a way to make the vertical and horizontal margins between the circles equal. Meaning all margins inside the arrangement of circles should be equal. In the above image, the circles are too large, the vertical distances are too much and the horizontal margins are too small.
- It requires quite a bit of code, I wonder if there is a more convenient way to tell which circles should have which color.