3

Below is a MWE that demonstrates my problem. The problem is how the labels move through each slide. It seems as though they are first right aligned and then become centered for the next slide. How can I have each label centered under the tick mark on every slide so that the diagram doesn't move between slides.

\documentclass{beamer}

\usepackage{pgfplots}

\begin{document}


\begin{frame}{Minimal Example}

\begin{tikzpicture} 
    \begin{axis}[
        font=\tiny,
        % enlarge y limits={value=0.2,upper},
        % scaled ticks=false, 
        xticklabels={,
        \only<4>{\phantom{$\mu-3\sigma$}}   \only<4->{$\mu-3\sigma$},
        \only<3>{\phantom{$\mu-2\sigma$}}   \only<3->{$\mu-2\sigma$},
        \only<2>{\phantom{$\mu-\sigma$}}    \only<2->{$\mu-\sigma$},
        $\mu$,
        \only<2>{\phantom{$\mu+\sigma$}}    \only<2->{$\mu+\sigma$},
        \only<3>{\phantom{$\mu+2\sigma$}}   \only<3->{$\mu+2\sigma$},
        \only<4>{\phantom{$\mu+3\sigma$}}   \only<4->{$\mu+3\sigma$},
        },
        yticklabels={,},
        ]
\addplot[blue]  coordinates {(0,0) (0,1) (6,1) (6,0)};
\addplot[red]   coordinates {(1,0) (1,2) (5,2) (5,0)};
\addplot[green] coordinates {(2,0) (2,3) (4,3) (4,0)};

\end{axis} 
\end{tikzpicture}

\end{frame}

\end{document}

The construction of showing labels between slides I took from this solution.

3

Rather than having the phantom placed on consecutive slides, you can have all of them only on the first slide, then uncover the subsequent labels on the next slides. The following should work:

\documentclass{beamer}

\usepackage{pgfplots}

\begin{document}


\begin{frame}{Minimal Example}

\begin{tikzpicture} 
    \begin{axis}[
        font=\tiny,
        % enlarge y limits={value=0.2,upper},
        % scaled ticks=false, 
        xticklabels={,
        \only<1>{\phantom{$\mu-3\sigma$}}   \only<4->{$\mu-3\sigma$},
        \only<1>{\phantom{$\mu-2\sigma$}}   \only<3->{$\mu-2\sigma$},
        \only<1>{\phantom{$\mu-\sigma$}}    \only<2->{$\mu-\sigma$},
        $\mu$,
        \only<1>{\phantom{$\mu+\sigma$}}    \only<2->{$\mu+\sigma$},
        \only<1>{\phantom{$\mu+2\sigma$}}   \only<3->{$\mu+2\sigma$},
        \only<1>{\phantom{$\mu+3\sigma$}}   \only<4->{$\mu+3\sigma$},
        },
        yticklabels={,},
        ]
\addplot[blue]  coordinates {(0,0) (0,1) (6,1) (6,0)};
\addplot[red]   coordinates {(1,0) (1,2) (5,2) (5,0)};
\addplot[green] coordinates {(2,0) (2,3) (4,3) (4,0)};

\end{axis} 
\end{tikzpicture}

\end{frame}

\end{document}
  • Many thanks. This does indeed work, and doesn't include any vertical twitch. – Geoff Sep 27 '14 at 18:26
3

To stop all the bumping you can just enclose the plot into an overlayarea environment, The second argument will let you control the vertical positioning. Like this:

\documentclass{beamer}

\usepackage{pgfplots}

\begin{document}
\begin{frame}{Minimal Example}
\begin{overlayarea}{\textwidth}{.7\textheight}
\begin{tikzpicture}
    \begin{axis}[
        font=\tiny,
        xticklabel style={text depth=0pt},
        % enlarge y limits={value=0.2,upper},
        % scaled ticks=false,
        xticklabels={,
        \only<4->{$\mu-3\sigma$},
        \only<3->{$\mu-2\sigma$},
        \only<2->{$\mu x-\sigma$},
        $\mu$,
        \only<2->{$\mu+\sigma$},
        \only<3->{$\mu+2\sigma$},
        \only<4->{$\mu+3\sigma$},
        },
        yticklabels={,},
        ]
\addplot[blue]  coordinates {(0,0) (0,1) (6,1) (6,0)};
\addplot[red]   coordinates {(1,0) (1,2) (5,2) (5,0)};
\addplot[green] coordinates {(2,0) (2,3) (4,3) (4,0)};

\end{axis}
\end{tikzpicture}
\end{overlayarea}
\end{frame}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.