# Using \pause inside a tikzpicture environment in a beamer presentation

I am preparing a presentation using beamer. I would like to show a picture written using tikz in two steps.

This is my first attempt:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetheme{Berlin}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\draw[gray, thick] (-3,2) -- (3,2);
\draw[gray, thick, dotted] (-3.5, 2) -- (-3,2);
\draw[gray, thick, dotted] (3, 2) -- (3.5,2);
\draw[gray, thick] (-3,0) -- (3,0);
\draw[gray, thick, dotted] (-3.5, 0) -- (-3,0);
\draw[gray, thick, dotted] (3, 0) -- (3.5,0);
\draw[gray, thick] (-2,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1,1) ellipse (0.6 and 1);
\draw[gray, thick] (0,1) ellipse (0.6 and 1);
\draw[gray, thick] (-2.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-0.5,1) ellipse (0.6 and 1);
\draw[red, very thick] (0.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (1,1) ellipse (0.6 and 1);
\draw[gray, thick] (1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (2,1) ellipse (0.6 and 1);
\draw[gray, thick] (2.5,1) ellipse (0.6 and 1);

\draw (3.5, 1) node [anchor = west]{$M$};

\pause

\draw (0.5, 0) node [anchor = north, red]{$N$};
\draw[red, very thick] (-3.3,1.7) -- (2.6,1.7);
\draw[red, very thick, dotted] (-3.8, 1.7) -- (-3.3,1.7);
\draw[red,  very thick, dotted] (2.6, 1.7) -- (3.1,1.7);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


I.e. I've just used the command \pause inside the tikzpicture environment. Unfortunately this result is quite unsatisfactory because the blue strip on the bottom (produced by the theme Berlin) does not appear immediately, but at the second step.

How could I solve my problem?

Any help will be really appreciated. Thank you very much!

Instead of using the \pause command, use the \onslide command.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetheme{Berlin}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\onslide<1->{
\draw[gray, thick] (-3,2) -- (3,2);
\draw[gray, thick, dotted] (-3.5, 2) -- (-3,2);
\draw[gray, thick, dotted] (3, 2) -- (3.5,2);
\draw[gray, thick] (-3,0) -- (3,0);
\draw[gray, thick, dotted] (-3.5, 0) -- (-3,0);
\draw[gray, thick, dotted] (3, 0) -- (3.5,0);
\draw[gray, thick] (-2,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1,1) ellipse (0.6 and 1);
\draw[gray, thick] (0,1) ellipse (0.6 and 1);
\draw[gray, thick] (-2.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (-0.5,1) ellipse (0.6 and 1);
\draw[red, very thick] (0.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (1,1) ellipse (0.6 and 1);
\draw[gray, thick] (1.5,1) ellipse (0.6 and 1);
\draw[gray, thick] (2,1) ellipse (0.6 and 1);
\draw[gray, thick] (2.5,1) ellipse (0.6 and 1);

\draw (3.5, 1) node [anchor = west]{$M$};
}
\onslide<2>{
\draw (0.5, 0) node [anchor = north, red]{$N$};
\draw[red, very thick] (-3.3,1.7) -- (2.6,1.7);
\draw[red, very thick, dotted] (-3.8, 1.7) -- (-3.3,1.7);
\draw[red,  very thick, dotted] (2.6, 1.7) -- (3.1,1.7);
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}