1. 程式人生 > >【Python科學計算】制作gif圖

【Python科學計算】制作gif圖

range test python ner code pri ges for 科學

??有時候繪制了一系列叠代圖,最直觀的展示方法是將其制作為 gif 圖,代碼為:

import imageio 
filenames = []
for i in range(100):
    filename = 'Generation '+str(i+1)+'.png'
    print(filename)
    filenames.append(filename)

img_paths = filenames 
gif_images = [] 
nums=1
for path in img_paths: 
    gif_images.append(imageio.imread(path)) 
    print(nums)
    nums=nums+1
imageio.mimsave("test.gif",gif_images,fps=5)

【Python科學計算】制作gif圖