The latest version of pyxll (5.4.0) allows animations generated in Matplotlib to be simply copied to Excel. A spreadsheet with the examples shown below, and the associated Python code can be downloaded from:
The screenshot below shows the simple example included in the pyxll documentation, and an animation of a 3D line graph from How to Animate Plots in Python. Learn the basics of …
Much more complex animations are also possible, such as these 3D surface animations from the SciPython Blog:
The Matplotlib animation functions also allow much smoother animations of the Mandelbrot Function than can be achieved with the VBA code I posted last year. The screenshot below shows input for generating a single Mandelbrot image on the left, and an animation zooming in on any defined point on the right:
If the “Update” input (Cell O9) is set to True (or 1) the animation will regenerate when any input value is changed, returning the new animation below the function input cell, and also the maximum zoom factor and the time to generate the animation in seconds. Note that the animation process is quite slow for complex images, and is approximately proportional to the number of steps squared. The example shown with 100 steps took almost 8 minutes; 10 steps will take less than 10 seconds. Once the animation has been generated it is saved with the Excel file, and will run without being regenerated, so the Update input should be set to False (or 0). The animation below shows the results of 100 steps, each zooming in by a factor of 1.2, with 200 milliseconds interval between each step:
The link at the top of this post includes a spreadsheet with all the animations shown above, and the Python code used to generate them. The code to generate new animations requires Python and Matplotlib, and the link to transfer new animations to the spreadsheet requires pyxll to run, but the animations saved with the spreadsheet will run without any external software.