I was wondering how to recreate the following image in Tikz. Where the main problem is creating the circles with different horizontal shades.

How can I recreate this image with the distinct shaded/coloured circles?


1 Answer 1


You can define the colored circle as a node with a path picture that colors some 1/n fractions of the horizontal distance. This style is called cc and cc=1,...,5 produces the colored circles. The coloring is dependent on the column index in a matrix, which also can be used to create O1,...,O5 automagically.

    marr/.style={semithick,->,shorten >=2pt,shorten <=1.5pt},
    cc/.style={circle,draw,inner sep=1ex,
        path picture={\foreach \XX in {1,...,#1}
        {\path[fill=c\the\numexpr#1+1-\XX\relax] (path picture bounding box.south west) rectangle
        ([xshift={-2pt+2*(\pgfkeysvalueof{/pgf/inner xsep}+3pt+\pgflinewidth)/\XX}]path picture bounding box.north west);}}}]
\matrix[matrix of nodes,nodes in empty cells,row sep=1em,
 row 1/.style={nodes={execute at begin node=O\the\pgfmatrixcurrentcolumn}},
 row 2/.style={nodes={cc=\the\pgfmatrixcurrentcolumn}},
 row 3/.style={nodes={text=c\the\pgfmatrixcurrentcolumn,
 text width={width("What")},align=center}}] (mat)
 { & & & & \\
  & & & & \\
  What & time & is & it & ? \\};
\foreach \X in {1,...,5} {
  \draw[marr] (mat-2-\X) -- (mat-1-\X);
  \draw[marr] (mat-3-\X) -- (mat-2-\X);
  \draw[marr] (mat-2-\X) -- (mat-2-\the\numexpr\X+1);

enter image description here

  • 2
    The answer to this question is obviously "Hibernation Time".
    – user194703
    Commented Apr 10, 2020 at 23:36
  • Thanks a bunch! this is perfect. Looks like magic to me but if it works, it works
    – Rien
    Commented Apr 10, 2020 at 23:41
  • 1
    @Rien You're welcome! (And you seem to be surprised that catcodes work. They get used all time. ;-)
    – user194703
    Commented Apr 11, 2020 at 0:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .