Pixelated animations in Matplotlib

animation, matplotlib, python, scipy

Solution

This is what worked for me.

You can change the bitrate while creating the writer instance

import matplotlib.animation as animation

anim = animation.FuncAnimation(fig, ...)

FFMpegWriter = animation.writers['ffmpeg']
metadata = dict(title='Movie Test', artist='Matplotlib',
                comment='Movie support!')

# Change the video bitrate as you like and add some metadata.
writer = FFMpegWriter(fps=15, bitrate=1000, metadata=metadata)

Then you can save your video.

anim.save("path.mp4", writer=mywriter)

Hope it helps

Problem

I've been using Matplotlib's animation facility to produce animated figures. I've noticed a problem which is particularly noticeable for animations with a large number of frames, which is that the quality of the figures deteriorates very quickly resulting in pixelated - blurry looking output. Examples: Messy grid lines pixelated output I've been rendering animations using ``` import matplotlib matplotlib.use("Agg") anim = animation.FuncAnimation(fig, ..., blit=False) mywriter = animation.FFMpegWriter(fps=15) anim.save("path.mp4", writer=mywriter) ``` I've tried using blit=True/False but haven't noticed much difference. Matplotlib version: 1.4.2. System: Mac 10.10

Original source

Related problems