TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I uncover the nodes in the following tikzpicture? I want to display all red nodes, followed by all green nodes, and then followed by all blue nodes.

\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill,inner sep=0pt,minimum size=4pt]
\tikzstyle{edge from parent}=[segment length=1mm,
                          segment angle=10,draw] 
\begin{tikzpicture}[grow cyclic,shape=circle,very thick,level distance=13mm,
\node {} child [color=\A] foreach \A in {red,red,red}
{  node {} child [color=\A!50!\B] foreach \B in {green,green,green}
     { node {} child [color=\A!50!\B!50!\C] foreach \C in {blue,blue,blue}
         { node {} }
share|improve this question
While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill May 20 '12 at 7:22
Note that \tikzstyle is deprecated. See e.g. Should \tikzset or \tikzstyle be used to define TikZ styles? – Martin Scharrer May 20 '12 at 9:53
@PeterGrill: Thanks for the note. I would provide MWE for my questions. – Sandeep May 21 '12 at 0:56
up vote 19 down vote accepted

In this solution I applied the Daniel's method shown in tikzpicture in beamer: it has several advantages and it is very simple to be used.

In the following code, with respect to the MWE provided, I shifted in the preamble the style definitions:


% style definitions
\tikzset{level 1/.style={sibling angle=120}}
\tikzset{level 2/.style={sibling angle=60}}
\tikzset{level 3/.style={sibling angle=30}}
\tikzset{every node/.style={fill,inner sep=0pt,minimum size=4pt}}
\tikzset{edge from parent/.style={segment length=1mm,
                          segment angle=10,draw}}

% Daniel's code:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer/55827#55827
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path

\begin{tikzpicture}[grow cyclic,shape=circle,very thick,level distance=13mm,
\node {} child [color=\A,visible on=<1->] foreach \A in {red,red,red}
{  node {} child [color=\A!50!\B,visible on=<2->] foreach \B in {green,green,green}
     { node {} child [color=\A!50!\B!50!\C,visible on=<3->] foreach \C in {blue,blue,blue}
         { node {} }


What you simply have to do, once inserted in the preamble the Daniel's code, is to define in which time instant you want to display nodes; the method is to add in child options visible on=<...>.

Finally, what you get are those three frames:

enter image description here

share|improve this answer
Thanks Claudio, Martin. This I would try this out. – Sandeep May 21 '12 at 0:57
A really cool feature of this approach is that you can even use visible on=<\slide-> in a \foreach \slide in {...} loop. This is also not possible with the standard TikZ syntax. – cgogolin Mar 8 at 17:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.