Jumping frame contents with beamer and pgfplots
This what the overlay-beamer-styles
edit is for. In addition, I like the [t]
option, which does not help here, but in general it helps avoiding jumps when working with \only
. In addition I gave the y ticks a fixed width. (Your plot is a bit too wide.)
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{overlay-beamer-styles}
\begin{document}
\begin{frame}[t]% <- I prefer [t] to avoid jumps
text
\begin{center}
\begin{tikzpicture}
\pgfplotsset{scaled ticks=false,ytick style={text
width=2cm,align=right},
ticklabel style={/pgf/number format/fixed,/pgf/number format/1000 sep={\,}},
width=11cm,
height=6cm}
\begin{axis}[visible on=<1>]
\addplot [domain=0:5] {x^3};
\end{axis}
\begin{axis}[visible on=<2>]
\addplot [domain=0:15] {x^3};
\end{axis}
\begin{axis}[visible on=<3>]
\addplot [domain=0:100] {x^3};
\end{axis}
\begin{axis}[visible on=<4>]
\addplot [domain=0:1000] {x^3};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
This allows zooming out by fixing the axis size and the bounding box.
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\begin{document}
\begin{frame}
text
\begin{center}
\begin{tikzpicture}
\path (-2.5cm,-1.5cm) (8.5cm,4.5cm);% bounding box
\begin{axis}[
scaled ticks=false,
ticklabel style={/pgf/number format/fixed,/pgf/number format/1000 sep={\,}},
width=8cm,
height=4cm,
scale only axis,
%enlargelimits=false% not needed after all
]
\only<1>{ \addplot [domain=0:5] {x^3}; }
\only<2>{ \addplot [domain=0:15] {x^3}; }
\only<3>{ \addplot [domain=0:100] {x^3}; }
\only<4>{ \addplot [domain=0:1000] {x^3}; }
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}