# Overlay in Beamer [duplicate]

I have 2 slides with the same plots on the top and with different equation on the bottom. The length of the equation are different, which results in different position of the same plot. When I get to the 2nd slides, there is a 'jump' of the plot. I tried to use the command \alt but failed. A simplified version of code is below.

\documentclass[british]{beamer}

\usepackage{pgf}
\usepackage{pgfplots}
\usepackage{tikz}

\usetikzlibrary{arrows}
\usetikzlibrary{arrows,external}

\newcommand{\dd}[2]{\frac{\partial #1}{\partial #2}}

\usepackage{babel}
\begin{document}

\begin{frame}
\noindent

%%%%%%%%%%%%plot%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.5cm,y=1.0cm]
\clip(-3.7,-1) rectangle (4.5,1.3);
\draw[color=green] (-3.5,-0.45) rectangle (4,0.45);
\end{tikzpicture}
%%%%%%%%%%%%plot%%%%%%%%%%%%%%%%%%%%%

$U-h\dd{U}{x}\left(\frac{4a_{0}a_{2}+2a_{0}a_{1}+(6-12a_{0}/H)a_{1}a_{2}}{8a_{0}a_{1}a_{2}H}\right)=c,$

\end{frame}

\begin{frame}
%%%%%%%%%%%%plot%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.5cm,y=1.0cm]
\clip(-3.7,-1) rectangle (4.5,1.3);
\draw[color=green] (-3.5,-0.45) rectangle (4,0.45);
\end{tikzpicture}
%%%%%%%%%%%%plot%%%%%%%%%%%%%%%%%%%%%

$H=aaaa$
\end{frame}

\end{document}

• Use an overprint environment and the onslide<...> command (within the same frame). Try \begin{overprint} \begin{tikzpicture}.../end{tikzpicture} \onslide<1> $U-h\dd{U}{x}\left(\frac{4a_{0}a_{2}+2a_{0}a_{1}+(6-12a_{0}/H)a_{1}a_{2}}{8a_{0}a_{1}a_{2}H}\right)=c,$ \onslide<2> $H=aaaa$ \end{overprint}. Jun 9 '13 at 10:09
• You find a practical example of the same concept in Get a includegraphic to stick in the same place for several beamer slides. Jun 9 '13 at 10:33