I draw some Brownian motions in beamer frame with the help of tikz(see Tom's codes). I want to obtain the following effect:
The Brownian motions is truncated by a positive integer. The panoramas of Brownian motions are showed when the positive integer increases.
I try to use some white rectangles for covering Brownian motions with \onslide
in beamer and draw a line below the rectangle. But the trajectory of Brownian motions changes when the line rises. Because Brownian motions will be drawn again when the overlay is generated by \onslide
. In every overlay the trajectories are different. Here is my MWE:
\documentclass{beamer}
\useoutertheme{infolines}
\usetheme{Darmstadt}
\usepackage{tikz}
\begin{document}
\begin{frame}{Brownian motions}
\begin{tikzpicture}[scale=0.6]
\draw[help lines] (0,0) grid (15,10);
\draw[red] (0,0)
\foreach \x in {1,2,...,750}
{ -- ++(0.02,rand*0.2+0.01) };
\draw[blue] (0,0)
\foreach \x in {1,2,...,750}
{ -- ++(0.02,rand*0.2+0.01) };
\draw[green] (0,0)
\foreach \x in {1,2,...,750}
{ -- ++(0.02,rand*0.2+0.01) };
\draw[orange] (0,0)
\foreach \x in {1,2,...,750}
{ -- ++(0.02,rand*0.2+0.01) };
\foreach \i in {1,2,...,7}
{
\onslide<\i>{
\draw[thick,red] (0,\i+3) -- ++(15,0);
\draw[white,fill=white,very thin] (0,\i+3) rectangle (15,11);
\draw[help lines] (0,\i+3) grid (15,10);
}
}
\draw[thick,->,>=stealth] (0,0) -- (16,0) node[right] {$t$};
\draw[thick,->,>=stealth] (0,0) -- (0,11) node[above] {$Y_t$};
\end{tikzpicture}
\end{frame}
\end{document}
See the following screenshot:
So I think if I can fix the trajectories, the effect I want will be obtained easily.
I also try to use the following method:
First, draw the trajectories in another document; then use the trajectories as a single pdf with '\includegraphics'.
But I also want to delete the red, orange and green trajectories and leave the blue one alone in the last overlay. Then fixing the trajectories is also important for deleting the trajectories.
How can I get the effect talked above? I really appreciate your work.
\pgfmathsetseed{<some integer>}
before the first set of\draw
commands, the random number generator will be reset for each slide and so always generate the same paths (Tom mentioned this in his answer). – Jake Jun 16 '12 at 7:29\pgfmathsetseed
. But I do not know what effect this code can generate. Sorry for ingore it. – XIAO Lishun Jun 16 '12 at 7:56