Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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,
                cap=round,scale=0.5]
\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 {} }
    }
};
\end{tikzpicture}
share|improve this question
1  
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
2  
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

1 Answer 1

up vote 17 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:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{trees,decorations}
\usetheme{EastLansing}

% 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
  \tikzset{
    invisible/.style={opacity=0},
    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{document}
\begin{frame}{Title}
\begin{center}
\begin{tikzpicture}[grow cyclic,shape=circle,very thick,level distance=13mm,
                cap=round,scale=0.5]
\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 {} }
    }
};
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}

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

Your Answer

 
discard

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.