Quantcast
Channel: WP快站
Viewing all articles
Browse latest Browse all 233

Saving a gif file Python

$
0
0

I'm trying to save an animation using the following code snippet:

import matplotlib.animation as animation import matplotlib.pyplot as plt import copy......frames = []for i in range(500):    config_copy = copy.deepcopy(config)    frames.append((plt.imshow(config_copy, cmap='Greys_r', aspect=1,         interpolation='none', vmin=-1, vmax=1), plt.scatter(loc[1], loc[0], c='red', marker='o', s=50)))...animation = FuncAnimation(f, lambda x: x, frames=frames, blit=True, interval=200)animation.save('fun_animation_random_direction.gif', writer='imagemagick', fps=30)plt.show()

When I run my code, the animation appears as it should be! But when I open the resulting gif file, I only see a picture which seems to show all frames at the same time. How can I resolve this issue?

I tried to open the gif file with other apps than the Windows photo viewer, but no success...


Viewing all articles
Browse latest Browse all 233

Trending Articles