Animation in diagrams (presentations in Latex)

While most people draw diagrams in Xfig (or GIMP) and include them in LaTeX, they can be drawn directly in LaTeX (using tikz package).
A major advantage of doing that is animation (\pause) is possible when using these diagrams in presentations(based on beamer)

Following is an example demonstrating that (code released under BSD license)

\tikzstyle{ablock} = [ellipse, draw, thin, fill=blue!20, minimum height=2.5em]
\begin{tikzpicture}[node distance=3cm, auto,>=latex', thick]
% We need to set at bounding box first. Otherwise the diagram
% will change position for each frame.
\path[use as bounding box] (-2,0) rectangle (5,-10);
\path[->]<1-7> node[ablock] (init) {Prefetch Request in MHT};
\path[->]<2-8> node[ablock, below of=init, xshift=5cm, yshift=1cm] (merged) {Delayed Prefetch}
(init) edge node {demand request by LSU} (merged);
\path[->]<3-7> node[ablock, below of=init, xshift=-2cm, yshift=1cm] (fetched) {Fetched in Dcache}
(init) edge node {} (fetched);
\path[->]<4-7> node[ablock, below of=fetched, xshift=-1cm, yshift=1cm] (useless) {Useless Prefetch}
(fetched) edge node {Evicted} (useless);
\path[->]<5-7> node[ablock, below of=fetched, xshift=3cm, yshift=1cm] (useful) {Useful Prefetch}
(fetched) edge node {Requested by LSU} (useful);
\path[->]<6-8> node[ablock, below of=useful, xshift=5cm, yshift=1cm] (early) {Early Prefetch}
(useful) edge node {Accessed after a long time} (early);
\path[->]<7-7> node[ablock, below of=useful, xshift=0cm, yshift=1cm] (timely) {Timely Prefetch}
(useful) edge node {Accessed within reasonable time} (timely);


2 Replies to “Animation in diagrams (presentations in Latex)”

  1. A Better way is to use the PSTricks package. It has more features.

  2. AFAIK PSTricks does not work with pdfLatex (which I use)

Leave a Reply