2

I occasionally use Mathematica to create animated graphs with parameters that I can change in real time as the animation runs. I find this is particularly effective to demonstrate the behavior of physical systems for students. An example Mathematica for one of the simpler animations is:

freq = 100*^6
lambda = 3*^8/freq
alpha = 0 
TLineLength = 10*lambda
AmplitudePlus = 2
PhasePlus = (2*Pi/180)*0
AmplitudeMinus = AmplitudePlus*0.5
PhaseMinus = (2*Pi/180)*0
GammaL = 0
Manipulate[Plot[AmplitudePlus*Cos[2*Pi*freq *t - (2*Pi/lambda)*z + PhasePlus]*
           Exp[-alpha*(TLineLength + z)], {z, -TLineLength, 0}, 
           PlotRange -> AmplitudePlus, AxesLabel -> {z [m], SuperPlus[V]}], {t,
           0, 10/freq}, {PhasePlus, 0, 2*Pi}, {alpha, 0, 1/(2*lambda)}]

I would love to do this in ipython notebooks instead of Mathematica. I have tried using interact similar to the answers to this question, but interact does not support animations as far as I've been able to determine. Also, generated graphs have a lot of flicker as you move a slider widget to control a parameter. I've also tried FuncAnimate, but have been entirely unsuccessful getting this to run inline in an ipython notebook (which I'm running on mac OS X 10.9). Even if I could get it to run, I wouldn't be able to change any parameters in real time as the animation runs. I would welcome advice or suggestions.

Community
  • 1
  • 1
alwaysCurious
  • 523
  • 5
  • 14
  • Can you provide the python equivalent of that plot (without the manipulate of course), so that people can play around with it? (I understand your question is more general, but I've never been bothered by the flicker of the ipython widgets, so it might have to do with your particular needs – cd98 Jan 11 '15 at 11:58
  • We do consider interact the closest equivalent of manipulate in IPython. Making it work with animations could be an interesting project for someone. – Thomas K Jan 12 '15 at 18:26
  • How does one get involved in such a project? I'm wondering if I can find a student here who might be interested. – alwaysCurious Jan 14 '15 at 16:10
  • @cd98 - This doesn't exactly answer your question, but I put together an ipython notebook (http://nbviewer.ipython.org/github/gregnordin/PythonShare/blob/master/matplotlib/matplotlib_backends_summary.ipynb) that summarizes what happens when you try to use animation and/or interact from a notebook. Also, I found that the flicker with interact is significantly more pronounced on mac os x than in Windows 7. – alwaysCurious Jan 14 '15 at 16:14

0 Answers0