Animation Jupyter notebook
Bonjour
J'ai trouvé un moyen d'avoir des animations sur jupyter en utilisant %matplotlib notebook comme ceci
Bien à vous.
J'ai trouvé un moyen d'avoir des animations sur jupyter en utilisant %matplotlib notebook comme ceci
import numpy as np import scipy.stats as st %matplotlib notebook import matplotlib.pyplot as plt import matplotlib.animation as animationpar exemple ici ça marche.
n = 100 X = st.norm(0,1).rvs(200) number_of_frames = np.size(X) def update_hist(num, second_argument): plt.cla() plt.hist(X[:num], bins = 20) plt.title("{}".format(num)) plt.legend() fig = plt.figure() hist = plt.hist(X) ani = animation.FuncAnimation(fig, update_hist, number_of_frames, fargs=(X, ), repeat = False ) plt.show()Ce qui est très louche c'est que ici ça ne marche plus
N_max = 100 X = np.linspace(-5,5, N_max ) number_of_frames = np.size(X) N = np.arange(1,N_max+1) h = 1/np.sqrt(N) def update_plot(n): #plt.cla() lines.set_data(X, np.array([f(x) for x in X])) lines2.set_data(X, np.array([fen(sample_sort[:n],h[n],x) for x in X])) ax.set_title("n = {}".format(n)) return lines, lines2 fig = plt.figure() ax = plt.axes(xlim=(-4, 4), ylim=(-0.01, 1)) lines, = ax.plot([], [], 'y-', lw=2, label="d") lines2, = ax.plot([], [], 'b--', lw=3, label="f") ani = animation.FuncAnimation(fig, update_plot, number_of_frames, repeat = False ) plt.show()pourtant pour moi c'est la même chose.
Bien à vous.
Réponses
-
J'ai tenté une modification. Maintenant j'ai une courbe mais pas d'animation.
Connectez-vous ou Inscrivez-vous pour répondre.
Bonjour!
Catégories
- 163.1K Toutes les catégories
- 8 Collège/Lycée
- 21.9K Algèbre
- 37.1K Analyse
- 6.2K Arithmétique
- 53 Catégories et structures
- 1K Combinatoire et Graphes
- 11 Sciences des données
- 5K Concours et Examens
- 11 CultureMath
- 47 Enseignement à distance
- 2.9K Fondements et Logique
- 10.3K Géométrie
- 62 Géométrie différentielle
- 1.1K Histoire des Mathématiques
- 68 Informatique théorique
- 3.8K LaTeX
- 39K Les-mathématiques
- 3.5K Livres, articles, revues, (...)
- 2.7K Logiciels pour les mathématiques
- 24 Mathématiques et finance
- 312 Mathématiques et Physique
- 4.9K Mathématiques et Société
- 3.3K Pédagogie, enseignement, orientation
- 10K Probabilités, théorie de la mesure
- 772 Shtam
- 4.2K Statistiques
- 3.7K Topologie
- 1.4K Vie du Forum et de ses membres
In this Discussion
Qui est en ligne 1
1 Invité