python - Matplotlib 中的像素化动画

标签 python animation matplotlib scipy

我一直在使用 Matplotlib 的动画工具来制作动画人物。我注意到一个问题,对于具有大量帧的动画来说尤为明显,即图形的质量会迅速恶化,从而导致像素化 - 输出看起来很模糊。

例子:

凌乱的网格线 Messy grid lines

像素化输出 pixilated output

我一直在使用渲染动画

import matplotlib
matplotlib.use("Agg")

anim = animation.FuncAnimation(fig, ..., blit=False)
mywriter = animation.FFMpegWriter(fps=15)
anim.save("path.mp4", writer=mywriter)

我试过使用 blit=True/False,但没发现有太大区别。

Matplotlib 版本:1.4.2。系统:Mac 10.10

最佳答案

这对我有用。

您可以在创建写入器实例时更改比特率

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)

然后您就可以保存您的视频了。

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

希望对你有帮助

关于python - Matplotlib 中的像素化动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28785118/

相关文章:

python - 如何在 python matplotlib 中设置限制范围 (xlim)?

python - 从 DateTime 数据框列中提取时间并使用线图绘制每小时时间

python - 在 python json.dumps 输出中禁用科学记数法

javascript - 如何识别负责转轮动画的代码并设计其样式

python - 将文本文件转换为 plink PED 和 MAP 格式

java - 如何在小程序上绕角旋转矩形?

javascript - jQuery:动画序列图像

python - 绘制非对称误差线 Matplotlib

python - Scrapy中的顺序请求调用

python - 在 Python 中将 matplotlib View 设置为垂直于 x-y 平面