All singing, all dancing 3d function plots with beamer, pgfplots and animate.sty

latent 1 150x150 All singing, all dancing 3d function plots with beamer, pgfplots and animate.sty

Source: Long/Freese, Regression Models for Categorical Dependent Variables Using Stata

I use emacs/\LaTeXfor all my textprocessing needs, and for the last four or five years, I have created all my slides with Till Tantaus excellent “beamer” class. At the moment, I’m teaching a 2nd year stats course (imagine doing this with PowerPoint – the horror! the horror!), so I sometimes use graphs from the assigned text like this one from Long&Freese that illustrates the latent variable/threshold interpretation of the binary logit model. The message should be fairly clear: y^{*} depends on x andfollows a standard logistic distribution around its conditional mean.

animation 300x224 All singing, all dancing 3d function plots with beamer, pgfplots and animate.sty

Click to download the animated PDF. Requires javascript, so view in Acrobat reader.

But the fact that the bell-curve lies flat in the x-y^{*} plane confused my students no end. So I wasted half a day on creating a nice 3d-plot for them. After trying several options, I settled on pgfplots.sty, which builds on tikz/pgf, the comprehensive, portable graphics package designed by Tantau (here’s a gallery with most amazing examples of what you can do with this little gem). Plotting data and functions with pgfplots in 2d or 3d is a snap, so that was not too hard. Eventually.

Finally, in a desperate attempt to drive the message home, I enlisted the help of animate.sty, yet another amazing package that creates a javascript-based inline animation from my \LaTeX source (requires Acrobat reader). So the bell-curves pop out of the plane, in slow motion. Did it help the students to see the light? I have no idea. Here is the source.

Reblog this post [with Zemanta]
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • connotea
  • email
  • LinkedIn
  • MisterWong
  • Ping.fm
  • StumbleUpon
  • Technorati
  • Netvibes
  • Propeller
  • Reddit
  • NewsVine
  • FriendFeed
  • PDF
  • Print
  • RSS
  • Wikio

Technorati Tags: , , , , , , , , , , , ,

Related posts

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

3 Comments »»

  1. Simon#

    Comment – 26. January 2010 – 10:18 pm

    Great work!
    Still singing and dancing ;-)

  2. Alexander – #

    Comment – 15. February 2010 – 11:00 am

    I had a look into the source file animation.tex.

    The part that creates the animation frames using the parameterized macro \doit can be significantly simplified by replacing the \whiledo loop with the \multiframe command. Note that the parameter names xb and xc had to be prefixed with `r’ to declare them as `real’ numbers (See the doc animate.pdf for details.).


    \begin{animateinline}{9}
    \multiframe{15}{rxb=90+-5,rxc=0+5.5}{%
    \doit{\rxc}{\rxb}%
    }
    \end{animateinline}

  3. kai#

    Comment – 16. February 2010 – 8:50 am

    Thanks for that Alexander. I tweaked an existing example to my needs, but your solution is obviously much more concise!

Leave a comment.

XHTML (You can use these elements): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>