2013-02-01 2 views
3

예제 from here을 사용하여 matplotlib로 애니메이션을 만들려고합니다. 처음에는 ffmpeg가 설치되지 않았기 때문에 macports에서 설치했습니다. 그러나 'rgba'는 지원되지 않습니다. 오류 메시지 : 이제matplotlib 형식의 애니메이션 "rgba"가 지원되지 않습니다.

File "Plot_shocktube1D.py", line 85, in <module> 
    animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264']) #, writer=movWriter) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 615, in save 
    writer.grab_frame() 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 199, in grab_frame 
    dpi=self.dpi) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1363, in savefig 
    self.canvas.print_figure(*args, **kwargs) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2012, in print_figure 
    print_method = self._get_print_method(format) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1953, in _get_print_method 
    '%s.' % (format, ', '.join(formats))) 
ValueError: Format "rgba" is not supported. 
Supported formats: bmp, emf, eps, gif, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff. 

대신 rgbapng를 사용하지만, 지금은 새로운 오류를 받고 있어요 몇 가지 어려움을 겪고 I 설정 FFMpegWriter 후 ...

오류가있는
movWriter = anim.FFMpegWriter(fps=5, codec=None, bitrate=None, extra_args=None, metadata=None) 
movWriter.frame_format = 'jpg' 
animDensity = anim.FuncAnimation(fig, animateDensity, frames=10, interval=100, blit=True) 
animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264'], writer=movWriter) 

:

File "Plot_shocktube1D.py", line 85, in <module> 
    animDensity.save(densityAnimationName, extra_args=['-vcodec', 'libx264'], writer=movWriter) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 615, in save 
    writer.grab_frame() 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/animation.py", line 199, in grab_frame 
    dpi=self.dpi) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py", line 1363, in savefig 
    self.canvas.print_figure(*args, **kwargs) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2093, in print_figure 
    **kwargs) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 326, in print_jpg 
    self._print_bitmap(filename, *args, **kwargs) 
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 319, in _print_bitmap 
    self.write_bitmap(filename, width, height, dpi) 
ValueError: Unknown file type 

나는 내가 필요로하는 설치물이 없다는 인상을 받고있다 ... 일반적으로 macports는 모든 것을 설정하고, 나는 정말로 아니다. 봐야 할 곳. 어떤 도움이라도 대단히 감사하겠습니다.

답변

3

그 사용() 문은 나에게 도움이되지 않았다,하지만 난 당신과 같은 오류로 실행 IPython에서 작동하는 basic matplotlib animation example의 두 번째 부분을 얻으려고합니다. 나는 macports를 사용하여 ffmpeg를 설치했다가 rgba가 지원되지 않는 경고를 받았다. (rgba가 지원되는 형식 목록에도 불구하고!).

어쨌든, 나는 내가 EXPLICT FFMpegFileWriter (단지 FFMpegWriter)를 사용하는 경우, 모든 것이 OK 것을 발견하고, RGBA 문제가 멀리 가서 나는 가능한 M4V 파일을 가지고 :

import matplotlib.animation as animation 
fig2 = plt.figure() 

x = np.arange(-9, 10) 
y = np.arange(-9, 10).reshape(-1, 1) 
base = np.hypot(x, y) 
ims = [] 
for add in np.arange(15): 
    ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 30)),)) 

im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000, blit=True) 
im_ani.save('im.m4v', writer=animation.FFMpegFileWriter(), metadata={'artist':'Guido'}) 
1

솔루션, 나는, "AGG"라고하기 matplotlib 사용 일을 왜 아무 생각이 :

import matplotlib 
matplotlib.use("Agg") 
+1

나는 몰랐다을 왜 그런지 설명하지만 http://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server –

관련 문제