I used to do this according to Andrew's solution until I read his note #2, and it reminded me that PGF's keys can do pretty much anything. The key (excuse the pun) is to create a key that processes other keys conditional on the slide number:
\tikzset{onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}}
}}
Using \pgfkeysalso
doesn't reset the current key path, whereas \pgfkeys
or \tikzset
would. The .code args
key handler means that
onslide=<overlay specification>{keys}
causes the the following code to be expanded:
\only<overlay specification>{\pgfkeysalso{keys}}
Then you can use the key onslide=<overlay specification>{keys}
to set keys only on specific slides. The slightly inelegant twist is that if your overlay specification contains commas the entire pair of overlay spec and keys has to be embraced.
Here is a complete example:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}} % \pgfkeysalso doesn't change the path
}}
\tikzset{temporal/.code args={<#1>#2#3#4}{%
\temporal<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}{\pgfkeysalso{#4}} % \pgfkeysalso doesn't change the path
}}
\tikzstyle{highlight}=[red,ultra thick]
\begin{document}
\begin{frame}
\begin{figure}[h]
\begin{centering}
\begin{tikzpicture}[
system/.style={draw,rectangle,rounded corners=3,minimum width=2cm,text width=1.8cm,text centered},
node distance=2cm
]
\node [system,onslide=<3->{highlight},anchor=center] (fe) {Feature Extraction};
\node [system,onslide={<2,4>{green}}] (am) [right=of fe.center] {Acoustic Model};
\node [system,temporal=<3>{blue}{highlight}{green}] (lm) [right=of am.center] {Language Model};
\node [system] (d) [below=of lm.center] {Decoder};
\draw[->] (fe) |- (am);
\draw[->] (am) |- (d);
\draw[->] (lm) -- (d.north);
\end{tikzpicture}
\end{centering}
\end{figure}
\end{frame}
\end{document}
You will be disappointed about the jiggling of your picture when the line thickness keys are applied. You might have to avoid relative positioning to make that go away.
For more on key handlers like .code args
, see the pgfkeys
section of the TikZ-PGF manual.