4

私は私の問題を解決するのに役立つこの簡単な例に出くわしました:

"""
Pyplot animation example.

The method shown here is only for very simple, low-performance
use.  For more demanding applications, look at the animation
module and the examples that use it.
"""

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(6)
y = np.arange(5)
z = x * y[:,np.newaxis]

for i in xrange(5):
    if i==0:
        p = plt.imshow(z)
        fig = plt.gcf()
        plt.clim()   # clamp the color limits
        plt.title("Boring slide show")
    else:
       z = z + 2
       p.set_data(z)

    print "step", i
    plt.pause(0.5)

これはpyplotインターフェースでアニメーションを表示しますが、このアニメーションを何らかのムービー形式で保存したいのですが、方法はありますか?

4

2 に答える 2

4

1つの方法は、すべてのステップを画像として保存してから、ffmpegなどを使用してムービーにすることです。

于 2012-08-23T22:10:38.733 に答える
3

matplotlibアニメーションをビデオとして保存する別の方法は、この記事http://jakevdp.github.com/blog/2012/08/18/matplotlib-animation-tutorial/で説明されています。これは、アニメーションを時間とともに変化する描画関数として指定する、より高いレベルのソリューションを示しています。また、各フレームの保存に対処する必要はありません。

于 2012-08-24T06:51:50.247 に答える