Matplotlib animation won't save

I'm trying to learn how to create matplotlib animations using Jake Vanderplas's basic example , but I'm having trouble getting the shape to save.I installed ffmpeg on my Mac via homebrew.

The only changes I made was to add:

import matplotlib
matplotlib.use('TKAgg')

      

When I run this script, I get the following error:

anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
TypeError: save() got an unexpected keyword argument 'extra_args'

      

Based on many other similar questions, I tried to set the ffmpeg path with

plt.rcParams['animation.ffmpeg_path']

      

but this also gives me an error:

File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py", line 660, in __setitem__
  See rcParams.keys() for a list of valid parameters.' % (key,))
KeyError: 'animation.ffmpeg_path is not a valid rc parameter.See rcParams.keys() for a list of valid parameters.'

      

After removing the rcParams setting, I also tried adjusting the save command to avoid the above TypeError:

try:
    anim.save('basic_animation.mp4', fps=30, extra_args=['-vcodec', 'libx264'])
except TypeError:
    anim.save('basic_animation.mp4', fps=30)

      

This runs without error, but no mp4 file is generated. I've read every thread and tried every solution I can find, but nothing changes. The plt.show () call works fine. Can anyone point me in the right direction? Thank!

Update : I am using matplotlib version 1.1.1

+3


source to share





All Articles