2012-02-13 39 views
1

我有一個問題:如何保存Animation.Artist動畫?

我的程序運行良好,但是當我嘗試保存我繪製的動畫時,編譯器響應一個錯誤。

驗證碼:

import matplotlib.pyplot as plt 
import matplotlib.image as mpimg 
import matplotlib.animation as animation 

fig=plt.figure() 
for infile in glob.glob('*.png'): 
    img=mpimg.imread(infile) 
    imgplot=plt.imshow(img) 
    im_list2.append([imgplot]) 
ani = animation.ArtistAnimation(fig, im_list2, interval=50, blit=True) 

但是當我嘗試將它保存這樣的:

ani.save('Animation1.mp4') 

它返回一個錯誤:

WindowsError: [Error 2] The system could not find the given data.

+0

我提供了一個完整的小例子來展示問題,它會更容易回答。 – 2012-02-13 15:22:01

+0

如果你已經找到了你的問題的答案(如你對india_dourada答案的評論中給出的),你應該回答你自己的問題,並將其標記爲已接受。 – bmu 2012-05-17 08:12:18

回答

2

我認爲你是用相同的問題我幾天前:here是我發佈的問題!

我解決我的問題由c更改行163:\ Python27 \ LIB \站點包\ matplotlib \ animation.py從

proc = Popen(command, shell=False, stdout=PIPE, stderr=PIPE) 

proc = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) 

...然而,我不確定animation.py文件中的這個變化有多「安全」! See more info here

+0

Thx Man,錯誤沒有再顯示,但沒有保存:S任何想法??? – 2012-02-15 12:12:16

+0

就我而言,我沒有任何意外的麻煩。我的動畫被妥善保存在它應有的路徑中。 你知道你在哪個目錄下工作嗎? 我建議你在腳本開頭選擇你的目錄(例如,如果你有一個名爲D:/ CG/DREAM的文件夾): 'os.chdir('D:/ CG/DREAM')' 然後,檢查動畫是否保存在這個文件夾中。 – carla 2012-02-15 18:09:23

+0

佩德羅,現在工作嗎? – carla 2012-02-20 10:25:35