Site icon ashishb.net

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)

\usepackage{tikz}
\tikzstyle{ablock} = [ellipse, draw, thin, fill=blue!20, minimum height=2.5em]
\begin{figure}
\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);
\end{tikzpicture}
\end{figure}

 

Exit mobile version