Salut J'essaie de créer un film de 15 graphes gaussiens qui se déplacent vers la gauche (c'est essentiellement ce que le code est censé faire) Cependant, mon idée pour comment créer la boucle for pour créer les 15 graphiques n'a pas créé plus de 1, cela ne fait qu'accélérer l'animation. Un code similaire a fonctionné sur matlab. Il a créé 15 courbes gaussiennes différentes. Voici un exemple de mon code. toute aide serait appréciée. MerciPython: Représentation graphique et animation de plusieurs itérations du même graphe avec Python
import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('agg')
import matplotlib.animation as animation
Gamma=0.0005
q=1.6e-19
m=0.067*9e-31
B=10
Ec=(1.0567e-34)*B/m
#e=2.78
#E0=0+(1.0567e-34)*x*i/m
fig, ax = plt.subplots()
pass
x = np.arange(0, 3.4e-3, 1.7e-5) # x-array, third number is interval here, x is energy
line, = ax.plot(x, np.e**(-(x-((1.0567e-34)*1*1/m))**2/Gamma**2))
def animate(i):
for p in xrange(1,3):
line.set_ydata(np.e**((-(x-((1.0567e-34)*p*i/m))**2)/Gamma**2)) # update the data
return line,
#Init only required for blitting to give a clean slate.
def init():
line.set_ydata(np.ma.array(x, mask=True))
return line,
ani = animation.FuncAnimation(fig, animate, np.arange(0, 2, .01), init_func=init,
interval=10, blit=True)
Writer = animation.writers['ffmpeg']
writer = Writer(fps=20, metadata=dict(artist='Me'), bitrate=1800)
ani.save('QHanimati.mp4', writer=writer)
plt.show()
Où dans le code est le numéro 15? – ImportanceOfBeingErnest