I have this example code and it works. I'm really really new to python, and I come from Matlab and Octave. I need to manipulate variables inside a FOR loop (in different and more complex ways than in the given example), then I need the animation output in a gif file. With this code, I visualize the animation correctly with the fps I need, but I'm not able to find a simple way to save the animation I see when plt.show() into a gif file or into multiple png files. How could I do it ?
# basic animated mod 39 wheel in python
import matplotlib.pyplot as plt
import numpy as np
plt.close()
plt.rcParams.update({
"lines.color": "white",
"patch.edgecolor": "white",
"text.color": "lightgray",
"axes.facecolor": "black",
"axes.edgecolor": "lightgray",
"axes.labelcolor": "white",
"xtick.color": "white",
"ytick.color": "white",
"grid.color": "lightgray",
"figure.facecolor": "black",
"figure.edgecolor": "black",
"savefig.facecolor": "black",
"savefig.edgecolor": "black"})
plt.xlabel('real axis')
plt.ylabel('imaginary axis')
plt.title('events constellation')
plt.xlim(-4, 4)
plt.ylim(-4, 4)
plt.gca().set_aspect('equal', adjustable='box')
plt.draw()
mng = plt.get_current_fig_manager()
mng.full_screen_toggle()
for n in range(1,40):
cnums = 3 * np.exp(1j * 2 * np.pi * (1/39) * n)
x = cnums.real
y = cnums.imag
plt.scatter(x, y , label="event", marker="o", color="red", s=200)
plt.pause(1)
plt.show()