3

I want to generate an animation where the number of lines increases one by one. It works very well but the start image always has two lines.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\usepackage{animate}

\begin{document}

\begin{animateinline}[controls]{10}
  \multiframe{5}{iIndex=0+1}{
    \begin{tikzpicture}
      \begin{axis}[
      ymin=0, 
      ymax=100, 
      xmin=0, 
      xmax=10,
      ]
      \foreach \i in {0,1,...,\iIndex} {
        \addplot[
        mark=none,
        domain=0:10,
        ] {3*x+\i+5};
        }
      \end{axis}
    \end{tikzpicture}
  }
\end{animateinline}

\end{document}

I want that it starts with one line and not two as shown in the picture:

enter image description here

The animated PDF can be found here for a couple of days:

https://dl.dropboxusercontent.com/u/1833443/lala.pdf

1 Answer 1

3

Use \foreach \i in {0,...,\iIndex} instead. The 0+1 in the multiframe has set the increment to 1.

enter image description here

Code

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\usepackage{animate}


\begin{document}

\begin{animateinline}[controls]{10}
  \multiframe{5}{iIndex=0+1}{
    \begin{tikzpicture}
      \begin{axis}[
      ymin=0, 
      ymax=100, 
      xmin=0, 
      xmax=10,
      ]
      \foreach \i in {0,...,\iIndex} {
        \addplot[
        mark=none,
        domain=0:10,
        ] {3*x+\i+5};
        }
      \end{axis}
    \end{tikzpicture}
  }
\end{animateinline}

\end{document}
3
  • Doesn't increment foreach over all values? I don't quite get what's the difference. May 18, 2014 at 1:33
  • 1
    OK, let's look this in another way. Say \i in {0,1,...,0} for the first multiframe because of the \iIndex. The foreach will go through 1 before stop. so two line has been drawn. That is why the start image always has 2 lines.
    – Jesse
    May 18, 2014 at 1:39
  • I See. Thanks! The trick is that i define the stepsize in the multiframe Commando. May 18, 2014 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .