# Use multiple tikz picture with onslide command in the single frame in beamer

I have multiple tikz pictures in the single frame in beamer. In the first tikz picture I was able to use the only overlay and onslide command. However, for the second picture I am not able to achive the same effect. What I want is at onslide<4> onwards I want to show the contents on the second tikz picture.

The sample code inside a frame is as follows:

\begin{frame}
\frametitle{Age of Water under dye from all Rivers}

\only<1->{\begin{tikzpicture}
\centering
\node [](0,0)(start){ \includegraphics[clip,trim=10 370 400 10,width=0.8\textwidth,height=0.85\textheight]{figures/dye-rivers}};
%       \draw [step=0.5cm,thin,dotted] (-5,-4) grid(5,4);
%       \node [circle]at (-4.5,0){0};
\onslide<2->{\draw [red,fill=red!30](-4.3,-0.2)circle(0.1cm);
\draw [red,fill=red!30](-3.3,0)circle(0.1cm);
\draw [red,fill=red!30](-2.5,-0.7)circle(0.1cm);
\draw [red,fill=red!30](-4.,-0.8)circle(0.1cm);
\draw [red,fill=red!30](-4.,-1.2)circle(0.1cm);
\draw [red,fill=red!30](4.3,1.6)circle(0.1cm);
\draw [red,fill=red!30](3.3,2.7)circle(0.1cm);
\draw [red,fill=red!30](1.6,3.5)circle(0.1cm);
\draw [red,fill=red!30](1.3,3.5)circle(0.1cm);}
\node [rectangle,text width=4cm,red] at (5.5,3) (return) {$Q_2 = 169 A^{0.616}$     \linebreak Mason et. al. 1998};
\onslide<3-> \node [rectangle,text width=4cm,red] at (5,0) (return) {Smaller near the source     \linebreak Increases away from the source};
\onslide<3-> \draw [red](-3.3,-1.5) circle(0.7cm);%wolf bay small age
\end{tikzpicture}}

\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[clip,trim=400 370 0 0,width=0.8\textwidth,height=0.85\textheight]{figures/dye-rivers}};
\draw [step=0.5,dotted](-5,-4) grid (5,4);
\end{tikzpicture}

\end{frame}

• Instead of using Beamer's overlay commands, consider using TikZ keys to control overlay effects within a tikzpicture environment. See for example this answer: tex.stackexchange.com/a/55849/18228 Jun 21, 2013 at 23:38
• That works on only one tikz picture. I couldn't make it work for multiple tikz picture. Currently I have two tikz pictures in one frame. Jun 21, 2013 at 23:46
• You have several elements besides the images; what exactly should appear on each slide; in particular, on slide 4? Jun 21, 2013 at 23:47
• @GonzaloMedina From slide 4 onwards, I want to show the elements of the second tikzpicture only. Jun 21, 2013 at 23:49
• @Jdbaba Please see my answer. Is it something like that what you are trying to achieve? Jun 21, 2013 at 23:52

The overlay specification \only<1->{<text>} causes <text> to appear on all slides from slide 1 on. If you want to restrict the appearance of <text> just to a particular range, you can use something like \only<1,2,3>{<text>} or, more easily, using a range as in \only<1-3>{<text>} (one can also use more complex specifications like \only<1-3,5-7,9>{<text>} which means that <text> will appear on slides 1 to 3, 5 to 7 and 9). Section 9 Creating Overlays (particularly from the secons subsection on) contains the details for overlay specifications.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}
\frametitle{Age of Water under dye from all Rivers}

\only<1-3>{\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[height=4cm]{example-image-a}};
%       \draw [step=0.5cm,thin,dotted] (-5,-4) grid(5,4);
%       \node [circle]at (-4.5,0){0};
\onslide<2->{\draw [red,fill=red!30](-4.3,-0.2)circle(0.1cm);
\draw [red,fill=red!30](-3.3,0)circle(0.1cm);
\draw [red,fill=red!30](-2.5,-0.7)circle(0.1cm);
\draw [red,fill=red!30](-4.,-0.8)circle(0.1cm);
\draw [red,fill=red!30](-4.,-1.2)circle(0.1cm);
\draw [red,fill=red!30](4.3,1.6)circle(0.1cm);
\draw [red,fill=red!30](3.3,2.7)circle(0.1cm);
\draw [red,fill=red!30](1.6,3.5)circle(0.1cm);
\draw [red,fill=red!30](1.3,3.5)circle(0.1cm);}
\node [rectangle,text width=4cm,red] at (5.5,3) (return) {$Q_2 = 169 A^{0.616}$     \linebreak Mason et. al. 1998};
\onslide<3> \node [rectangle,text width=4cm,red] at (5,0) (return) {Smaller near the source     \linebreak Increases away from the source};
\onslide<3> \draw [red](-3.3,-1.5) circle(0.7cm);%wolf bay small age
\end{tikzpicture}}

\only<4->{\begin{tikzpicture}
\node [](0,0)(start){ \includegraphics[height=4cm]{example-image-b}};
\draw [step=0.5,dotted](-5,-4) grid (5,4);
\end{tikzpicture}}
\end{frame}

\end{document}


Just for the example I changed the clip commands; restore them in the actual code.

• Awesome. That is exactly what I wanted. I am learning latex recently and trying to make a presentation so I am having very simple questions. Thank you for your time and effort. Jun 21, 2013 at 23:55
• @Jdbaba You're welcome. I'm glad I could help. I'll add some explanation in a few minutes. Jun 21, 2013 at 23:57