# pgfplots + animate + foreach: Starting with one plot

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}

\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} {
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:

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

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

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

Code

\documentclass{article}
\usepackage{pgfplots}

\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} {
mark=none,
domain=0:10,
] {3*x+\i+5};
}
\end{axis}
\end{tikzpicture}
}
\end{animateinline}

\end{document}

• Doesn't increment foreach over all values? I don't quite get what's the difference. – Dr. Manuel Kuehner May 18 '14 at 1:33
• 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 '14 at 1:39
• I See. Thanks! The trick is that i define the stepsize in the multiframe Commando. – Dr. Manuel Kuehner May 18 '14 at 12:13