# Beamer: column alignment with tikzpicture inside

I am having trouble with using columns in Beamer class. For some reason, I have to display a plot in the left column, then replacing it with another plot to display additional data on it (I can not overlay within the plot itself since pgfplots does not support overlaying single coordinates, whatever...).

For this I have to use the \only<> command to display a picture, then another. My current issue is that I am not able to keep alignment of right column (which contains always the same elements) between different slides even within an overprint environment.

Here is a MWE

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[frenchb]{babel}
\usepackage{tikz}
\usetheme{Frankfurt}

\begin{document}

\begin{frame}\frametitle{test}
\begin{columns}[onlywidth,T]
\begin{column}{.7\textwidth}
\begin{overprint}
\centering
column 1\\
\only<2>{\tikz \draw (0,0) circle (.5cm);}
\only<3->{\tikz \draw[blue] (0,0) circle (2cm);}
\end{overprint}
\end{column}

\begin{column}{.3\textwidth}
\begin{overprint}
\centering
column 2\\
{\tikz \draw (0,0) circle (1cm);}
\end{overprint}
\end{column}

\end{columns}
\end{frame}

\end{document}


This MWE shows that column 2 has a little vertical shifts between slides 2 and 3. I don't get it : since I am in an overprint environment, column alignments should be done with the highest object enclosed, i.e. the blue circle, but it does not work.

I tried do change column alignment argument (t, T, c, etc.) and tried "overlayarea" but it didn't work either.

I hope you can help me.

-

For this kind of problems it is always better to rely to Daniel's method shown in tikzpicture in beamer. It helps to avoid the so called jumping effect and it is very easy to be used: you just have to specify as option when a path should be visible; in code: visible on=<...>.

The MWE revised:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lmodern} % to avoid the warning about font size substitution
\usepackage{tikz}
\usetheme{Frankfurt}

\tikzset{
invisible/.style={opacity=0,text opacity=0}, % added text opacity to fix problems when nodes' text is opaque
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}

\begin{document}

\begin{frame}\frametitle{test}
\begin{columns}[onlywidth,T]
\begin{column}{.7\textwidth}
\centering
column 1\\[1ex]
\tikz \draw[visible on=<2>] (0,0) circle (.5cm);
\tikz \draw[blue,visible on=<3->] (0,0) circle (2cm);
\end{column}

\begin{column}{.3\textwidth}
\centering
column 2\\[1ex]
\tikz \draw (0,0) circle (1cm);
\end{column}
\end{columns}
\end{frame}
\end{document}


The result:

Solving the right problem after the comment..

The approach is identical as did before: the visibility condition should be applied now to the \addplot.

The code:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{lmodern} % to avoid the warning about font size substitution
\usepackage{pgfplots}
\pgfplotsset{compat=1.7} % use just with an updated TeXLive distribution otherwise search for your current pgfplots version
\usetheme{Frankfurt}

\tikzset{
invisible/.style={opacity=0,text opacity=0}, % added text opacity to fix problems when nodes' text is opaque
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}

\begin{document}

\begin{frame}\frametitle{test}
\begin{columns}
\begin{column}{.49\textwidth}
\centering
\only<1>{The plot of $\exp x$}\only<2>{The plot of $\exp 3x$}\only<3>{The plot of $\exp 6x$}\\[1ex]
\begin{tikzpicture}
\begin{semilogyaxis}[width=\textwidth,font=\scriptsize]
\end{semilogyaxis}
\end{tikzpicture}
\end{column}

\begin{column}{.49\textwidth}
\centering
\only<1,2,3>{The plot of $\sin x$}\\[1ex]
\begin{tikzpicture}
\begin{axis}[width=\textwidth,font=\scriptsize]
[yshift=8pt]
node[pos=0] {$0$}
node[pos=0.25,below=0.25cm] {$\pi/2$}
node[pos=0.5] {$\pi$}
node[pos=0.75] {$3/2\pi$}
node[pos=1] {$2\pi$}
;
\end{axis}
\end{tikzpicture}

\end{column}
\end{columns}
\end{frame}
\end{document}


The result:

-
allright, thanks for your answer. It works well on this example, but in my real beamer project, I draw plots with pgfplots instead of simple circles and I really need to replace a plot with another. With your method, one disappears and the other appears but they have their own space and don't "substitute" to each other (this is why I used \only –  Flyingbike Nov 5 '12 at 16:23
I don't see the problem. Of course I you asked directly for that I will have answered with an example of that type before, but the approach is exactly the same. I'm gonna provide you a right example. As a new user, I would courteously suggest for the future to upvote all answers you find useful, including those to others' questions and to check/accept the best answers to your own questions by clicking the green tick on the left-hand side of the answer. –  Claudio Fiandrino Nov 5 '12 at 17:13
okay, I get it. Both answers are useful to me. Thanks again for using some of your time. –  Flyingbike Nov 6 '12 at 8:36