애니메이션을 GIF로 내보내는 중 오류 발생-Matplotlib

존 보이

애니메이션을 gif 형식으로 내보내려고합니다. mp4를 사용하여이 작업을 수행 할 수 있지만 gif로 변환 할 때 오류가 발생합니다. 스크립트가 잘못되었거나 일부 백엔드 설정인지 확실하지 않습니다.

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation

df1 = pd.DataFrame({
    'Time' : [1,1,1,2,2,2,3,3,3],        
    'GroupA_X' : [3, 4, 5, 12, 15, 16, 21, 36, 47], 
    'GroupA_Y' : [2, 4, 5, 12, 15, 15, 22, 36, 45],            
    'GroupB_X' : [2, 5, 3, 12, 14, 12, 22, 33, 41],   
    'GroupB_Y' : [2, 4, 3, 13, 13, 14, 24, 32, 45],                 
        })

fig, ax = plt.subplots()
ax.grid(False)
ax.set_xlim(0,50)
ax.set_ylim(0,50)

def groups():

    Group_A = df1[['Time','GroupA_X','GroupA_Y']]

    GA_X = np.array(Group_A.groupby(['Time'])['GroupA_X'].apply(list))
    GA_Y = np.array(Group_A.groupby(['Time'])['GroupA_Y'].apply(list))

    GA = ax.scatter(GA_X[0], GA_Y[0], c = ['blue'], marker = 'o', s = 10, edgecolor = 'black')

    return GA, GA_X, GA_Y

def animate(i) :

    GA, GA_X, GA_Y = groups()

    GA.set_offsets(np.c_[GA_X[0+i], GA_Y[0+i]])


ani = animation.FuncAnimation(fig, animate, np.arange(0,3), interval = 1000, blit = False)

# If exporting as an mp4 it works fine.

#Writer = animation.writers['ffmpeg']
#writer = Writer(fps = 10, bitrate = 8000)
#ani.save('ani_test.mp4', writer = writer)


#But if I try to export as a gif it returns an error:

ani.save('gif_test.gif', writer = 'imagemagick')

오류:

MovieWriter imagemagick unavailable. Trying to use pillow instead.

self._frames[0].save(
IndexError: list index out of range

참고 : 나는 또한 동일한 결과를 반환하는 다음을 시도했습니다. Index error

my_writer=animation.PillowWriter(fps = 10)
ani.save(filename='gif_test.gif', writer=my_writer)

다른 질문 animate gif 에서 수많은 설정을 조정 해 보았습니다 . 내 현재 애니메이션 설정은 다음과 같습니다. Mac을 사용하고 있습니다.

###ANIMATION settings
#animation.html :  none            ## How to display the animation as HTML in
                                   ## the IPython notebook. 'html5' uses
                                   ## HTML5 video tag; 'jshtml' creates a 
                                   ## Javascript animation
#animation.writer : imagemagick         ## MovieWriter 'backend' to use
#animation.codec : mpeg4            ## Codec to use for writing movie
#animation.bitrate: -1             ## Controls size/quality tradeoff for movie.
                                   ## -1 implies let utility auto-determine
#animation.frame_format:  png      ## Controls frame format used by temp files
#animation.html_args:              ## Additional arguments to pass to html writer
animation.ffmpeg_path: C:\Program Files\ImageMagick-6.9.1-Q16\ffmpeg.exe    ## Path to ffmpeg binary. Without full path
                                   ## $PATH is searched
#animation.ffmpeg_args:            ## Additional arguments to pass to ffmpeg
#animation.avconv_path:  avconv    ## Path to avconv binary. Without full path
                                   ## $PATH is searched
#animation.avconv_args:            ## Additional arguments to pass to avconv
animation.convert_path: C:\Program Files\ImageMagick-6.9.2-Q16-HDRI    ## Path to ImageMagick's convert binary.
                                   ## On Windows use the full path since convert
                                   ## is also the name of a system tool.
#animation.convert_args:           ## Additional arguments to pass to convert
#animation.embed_limit : 20.0
윌리엄 밀러

구성한 경로,

animation.ffmpeg_path: C:\Program Files\ImageMagick-6.9.1-Q16\ffmpeg.exe

animation.convert_path: C:\Program Files\ImageMagick-6.9.2-Q16-HDRI

Windows 용이지만 Mac 용이므로 MacOS 용 경로가 필요합니다. which터미널에서 사용할 수 있어야합니다 . 내 Ubuntu 설치 which에서 다음을 제공합니다.

>$ which convert
/usr/bin/convert

>$ which ffmpeg  
/usr/bin/ffmpeg

MacOS에서도 비슷해야합니다. 사람들은 rcParams에 공급해야하는 경로입니다 animation.convert_pathanimation.ffmpeg_path

animation.ffmpeg_path: /usr/bin/ffmpeg
animation.convert_path: /usr/bin/convert

matplotlib 구성에 잘못된 경로가 있으면 문제의 오류가 발생하지만 수정하면 오류가 해결되지 않을 수 있습니다. 다른 문제가있을 수도 있습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

TXTextControl을 PDFA 또는 XML로 내보내는 중 오류 발생

분류에서Dev

Meteor로 확인 이메일을 보내는 중 오류 발생

분류에서Dev

캘린더 항목을 ics 파일로 내보내는 중 오류 발생

분류에서Dev

Python : 두 개 이상의 이메일을 연속으로 보내는 중 오류 발생

분류에서Dev

Jaeger로 Java 애플리케이션을 추적하는 중에 오류가 발생했습니다.

분류에서Dev

Rails 애플리케이션을 Heroku로 푸시하는 중에 오류가 발생했습니다.

분류에서Dev

애니메이션 ffmpeg 내보내기 오류-Matplotlib

분류에서Dev

Excel로 데이터를 내보내는 동안 Pandas 오류 발생

분류에서Dev

Indesign에서 jsx 파일을 실행하여 각 텍스트 프레임을 .txt 파일로 내보내는 중 오류 발생

분류에서Dev

스타일 CSS로 배경을 애니메이션하는 동안 오류가 발생합니까?

분류에서Dev

Play 애플리케이션을 통해 Cassandra DB에 json 파일을 업로드하는 중 오류 발생

분류에서Dev

Angular $ resource로 요청을 가져 오는 중 오류 발생

분류에서Dev

tf.lookup.StaticHashTable을 사용하여 TF2.2.0 모델을 내보내는 중 오류 발생

분류에서Dev

Spark SQL 데이터 프레임을 CSV로 내보내는 동안 오류가 발생했습니다.

분류에서Dev

Vue-Router에서 경로를 교체하는 동안 내비게이션 중복 오류 발생

분류에서Dev

Excel로 내보내는 동안 ReleaseObject 오류 발생

분류에서Dev

Wine 5로 업데이트하는 중 오류 발생

분류에서Dev

Excel에서 데이터를로드하는 중 오류 발생

분류에서Dev

Android에서 Mandrill SMTP로 이메일을 보내려고 할 때 오류 발생

분류에서Dev

이메일 내용을 가져 오는 중에 오류가 발생했습니다.

분류에서Dev

로그 모니터링 : 오류 발생시 이메일 보내기

분류에서Dev

`plnkr`-타이프 스크립트`인터페이스`를 내보내는 동안`예기치 않은 토큰 내보내기`로 오류가 발생합니다.

분류에서Dev

IBM MQ를 사용하여 메시지 보내기, 2059 오류 발생 또는 큐 관리자 구성 중단

분류에서Dev

서버의 github에서 내 프로젝트를 복제하는 중에 오류가 발생했습니다.

분류에서Dev

보석 '야드'를로드하는 중에 오류가 발생했습니다.

분류에서Dev

사이트로 이동할 때 403 오류가 발생하는 이유는 무엇입니까? 내 컴퓨터 중 하나에서만 발생

분류에서Dev

함수에서 SQL 내보내기로 리턴하는 동안 오류가 발생했습니다.

분류에서Dev

버튼에서 SMS를 보내는 중에 오류가 발생했습니다. 기계적 인조 인간

분류에서Dev

IOREDIS-Redis에서 KeyDB로 마이그레이션하는 중 오류 발생

Related 관련 기사

  1. 1

    TXTextControl을 PDFA 또는 XML로 내보내는 중 오류 발생

  2. 2

    Meteor로 확인 이메일을 보내는 중 오류 발생

  3. 3

    캘린더 항목을 ics 파일로 내보내는 중 오류 발생

  4. 4

    Python : 두 개 이상의 이메일을 연속으로 보내는 중 오류 발생

  5. 5

    Jaeger로 Java 애플리케이션을 추적하는 중에 오류가 발생했습니다.

  6. 6

    Rails 애플리케이션을 Heroku로 푸시하는 중에 오류가 발생했습니다.

  7. 7

    애니메이션 ffmpeg 내보내기 오류-Matplotlib

  8. 8

    Excel로 데이터를 내보내는 동안 Pandas 오류 발생

  9. 9

    Indesign에서 jsx 파일을 실행하여 각 텍스트 프레임을 .txt 파일로 내보내는 중 오류 발생

  10. 10

    스타일 CSS로 배경을 애니메이션하는 동안 오류가 발생합니까?

  11. 11

    Play 애플리케이션을 통해 Cassandra DB에 json 파일을 업로드하는 중 오류 발생

  12. 12

    Angular $ resource로 요청을 가져 오는 중 오류 발생

  13. 13

    tf.lookup.StaticHashTable을 사용하여 TF2.2.0 모델을 내보내는 중 오류 발생

  14. 14

    Spark SQL 데이터 프레임을 CSV로 내보내는 동안 오류가 발생했습니다.

  15. 15

    Vue-Router에서 경로를 교체하는 동안 내비게이션 중복 오류 발생

  16. 16

    Excel로 내보내는 동안 ReleaseObject 오류 발생

  17. 17

    Wine 5로 업데이트하는 중 오류 발생

  18. 18

    Excel에서 데이터를로드하는 중 오류 발생

  19. 19

    Android에서 Mandrill SMTP로 이메일을 보내려고 할 때 오류 발생

  20. 20

    이메일 내용을 가져 오는 중에 오류가 발생했습니다.

  21. 21

    로그 모니터링 : 오류 발생시 이메일 보내기

  22. 22

    `plnkr`-타이프 스크립트`인터페이스`를 내보내는 동안`예기치 않은 토큰 내보내기`로 오류가 발생합니다.

  23. 23

    IBM MQ를 사용하여 메시지 보내기, 2059 오류 발생 또는 큐 관리자 구성 중단

  24. 24

    서버의 github에서 내 프로젝트를 복제하는 중에 오류가 발생했습니다.

  25. 25

    보석 '야드'를로드하는 중에 오류가 발생했습니다.

  26. 26

    사이트로 이동할 때 403 오류가 발생하는 이유는 무엇입니까? 내 컴퓨터 중 하나에서만 발생

  27. 27

    함수에서 SQL 내보내기로 리턴하는 동안 오류가 발생했습니다.

  28. 28

    버튼에서 SMS를 보내는 중에 오류가 발생했습니다. 기계적 인조 인간

  29. 29

    IOREDIS-Redis에서 KeyDB로 마이그레이션하는 중 오류 발생

뜨겁다태그

보관