我能夠使用imageio和mimsave解決此問題。
這是我的最終代碼:
filenames=[] # array that stores the filename of each image
for val in range(64):
ap_pix=amp_phas[:,val] # array that contains the image data
im=plt.imshow(ap_pix.reshape(50,50),cmap=plt.get_cmap('plasma'))
plt.colorbar()
a='C:/yada/yada/'+ str(val)+'.png' #filename of each array with the location where it is to be saved
filenames.append(a) # adding the file name to filenames[]
plt.savefig(a) #saving the figure
plt.clf() #clearing the figure so that the colorbars don't pile up
import imageio
images = [] #array to store the images
for filename in filenames:
images.append(imageio.imread(filename)) #reading the images into into images[]
imageio.mimsave('C:/yada/yada/movie.gif', images) #movie making
的GIF的幀速率可以通過以下方式進行調整:
imageio.mimsave('C:/yada/yada/movie.gif', images,duration=0.5)
請詳細信息添加到您的問題。你使用哪種編程語言?你需要什麼確切的輸出?創建**電影**並不能清楚地描述你想要的輸出。 – Nima