15

I want to put one figure with multiple curves in my beamer presentation, but I want to put a pause between the curves. It means that the curves appear in the plot one by one. The \pause option does not work. How can I do this?

\documentclass[10pt]{beamer}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}

\addplot table {error1 };
\pause

\addplot table {error3};
\pause

\addplot table {error5};
\pause

\end{axis}
\begin{document}
Hana
  • 361
  • This is probably not so relevant, because this is an old question that has answers already, but it seems to me that it is a duplicate of https://tex.stackexchange.com/q/6632/168128. – astoeriko Dec 08 '22 at 18:54

2 Answers2

22

Another option is using the visible on style:

\documentclass[10pt]{beamer}
\usepackage{pgfplots}

\tikzset{ invisible/.style={opacity=0}, 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} \begin{tikzpicture} \begin{axis} \addplot+[visible on=<1->] coordinates {(0,0) (5,3)}; \addplot+[visible on=<2->] coordinates {(0,-2) (5,-3)}; \addplot+[visible on=<3->] coordinates {(0,2) (5,0)}; \end{axis} \end{tikzpicture} \end{frame}

\end{document}

An animation of the result:

enter image description here

Note that if you want to show the same graph on multiple slides seperated by comma, you must write the argument in curly brackets: {<1,3>}

Gonzalo Medina
  • 505,128
13

Using \only seems to work.

\documentclass{beamer}
\usepackage{pgfplots}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\begin{axis}
\addplot {rnd};
\only<2->{
\addplot {rnd};}
\only<3>{
\addplot {rnd};}
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
Torbjørn T.
  • 206,688
  • 3
    Problem with this: rather than just being invisible, the plot will not actually be drawn in earlier frames, which can cause problems with the sizing of the picture. – Jordan Mitchell Barrett Aug 07 '20 at 09:46