matplotlib save animation in gif error

后端 未结 5 714
时光取名叫无心
时光取名叫无心 2020-11-29 08:58

I want to save matplotlib animation in gif format.

I succeded to save animation to mp4 format, using code

import matplotlib
matplotlib.use(\"Agg\")

         


        
5条回答
  •  忘掉有多难
    2020-11-29 09:11

    Still had some trouble on Mac OS X, but the answers above pointed me in the right direction.

    What I did came down to:

    1. brew install imagemagick
    2. edit the path file on location /etc/path (sudo vim path) and added the location of bin folder of imagemagick, in my case: /usr/local/Cellar/imagemagick/6.9.6-4/bin
    3. changed the settings of matplotlibrc as described above. You can find the location of matplotlibrc by doing in Python: import matplotlib matplotlib.matplotlib_fname() The settings you need to adjust can be found at the end of the file. I adjusted the following ones (commented out). Please note that those settings are not in 'quotes':

      animation.writer : imagemagick

      animation.codec : mpeg4

      animation.bitrate: -1

      animation.frame_format: png

      animation.convert_path: convert

提交回复
热议问题