[Tex/LaTex] Making Tikz images appear and disappear in beamer

beamertikz-pgf

I have a Tikz image that I want to appear at time 1 in my beamer slide. At time 2, I want the first Tikz image to disappear, and then a second tikz image appears in its place (not below the now vanished first tikz image).

\begin{frame}{Example} 
\begin{overlayarea}{\textwidth}{2cm}

\visible<1-1> {
\begin{center} \begin{tikzpicture}
\draw 
(0,0) -- (3,0);
\end{tikzpicture} \end{center}
}

\begin{center} \begin{tikzpicture}<2->
\draw 
(0,0) -- (3,0)
;

\end{tikzpicture} \end{center}
\end{frame}

But here the second image is not at the top of the slide.

Best Answer

How about this?

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}{Example} 
    \only<1>{%
        \begin{tikzpicture}
            \draw (0,0) -- (3,0);
        \end{tikzpicture} 
    }
    \pause
    \begin{tikzpicture}
        \draw (0,0) -- (3,0);   
    \end{tikzpicture} 
\end{frame}


\end{document}