init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.
ipynb
In [89]: import matplotlib.pyplot as plt
import numpy as np
In [90]: x=np.linspace(0,20,101)
y=np.sin(x)
x
Out[90]: array([ 0. , 0.2, 0.4, 0.6, 0.8, 1. , 1.2, 1.4, 1.6, 1.8, 2. ,
2.2, 2.4, 2.6, 2.8, 3. , 3.2, 3.4, 3.6, 3.8, 4. , 4.2,
4.4, 4.6, 4.8, 5. , 5.2, 5.4, 5.6, 5.8, 6. , 6.2, 6.4,
6.6, 6.8, 7. , 7.2, 7.4, 7.6, 7.8, 8. , 8.2, 8.4, 8.6,
8.8, 9. , 9.2, 9.4, 9.6, 9.8, 10. , 10.2, 10.4, 10.6, 10.8,
11. , 11.2, 11.4, 11.6, 11.8, 12. , 12.2, 12.4, 12.6, 12.8, 13. ,
13.2, 13.4, 13.6, 13.8, 14. , 14.2, 14.4, 14.6, 14.8, 15. , 15.2,
15.4, 15.6, 15.8, 16. , 16.2, 16.4, 16.6, 16.8, 17. , 17.2, 17.4,
17.6, 17.8, 18. , 18.2, 18.4, 18.6, 18.8, 19. , 19.2, 19.4, 19.6,
19.8, 20. ])
1 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [91]: plt.figure(figsize=(2,2))
plt.plot(x,y)
plt.xlabel('Axe des abscisses')
plt.ylabel('Axe des ordonnées')
plt.grid()
plt.title('Courbe de la fonction sin(x)')
Out[91]: Text(0.5, 1.0, 'Courbe de la fonction sin(x)')
In [92]: # Données à visualisées
prix_ws=[30,50,57,69,94,100]
prix_apple=[93,112,104,144,170,172]
annee=[2015,2016,2017,2018,2019,2020]
2 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [93]: # Visualisé les données
plt.figure(figsize=(3,2))
plt.plot(annee, prix_ws, label='Prix des windows', c='r')
plt.plot(annee, prix_apple, label='Prix des apples', c='g')
plt.xlabel('Année de vente')
plt.ylabel('Prix des appareils')
plt.legend()
plt.savefig('graphe.jpg')
plt.title("Variation du prix de vente en fonction de l'année")
Out[93]: Text(0.5, 1.0, "Variation du prix de vente en fonction de l'année")
3 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [94]: plt.figure(figsize=(3,2))
plt.bar(annee, prix_ws, label='Prix des windows')
Out[94]: <BarContainer object of 6 artists>
4 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [95]: # Diagramme circulaire
produits=['P1','P2','P3','P4']
vente=[10,20,20,50]
plt.pie(vente, labels=produits,autopct='%1.1f%%')
Out[95]: ([<matplotlib.patches.Wedge at 0x23287bed750>,
<matplotlib.patches.Wedge at 0x23287bed690>,
<matplotlib.patches.Wedge at 0x23287bee560>,
<matplotlib.patches.Wedge at 0x23287beed10>],
[Text(1.0461621663333946, 0.3399186987098808, 'P1'),
Text(0.33991867422268784, 1.0461621742897658, 'P2'),
Text(-0.8899187180267095, 0.6465637441936395, 'P3'),
Text(5.149471664411206e-08, -1.0999999999999988, 'P4')],
[Text(0.5706339089091244, 0.1854101992962986, '10.0%'),
Text(0.1854101859396479, 0.5706339132489631, '20.0%'),
Text(-0.48541020983275057, 0.3526711331965306, '20.0%'),
Text(2.8088027260424755e-08, -0.5999999999999993, '50.0%')])
5 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [96]: plt.figure(figsize=(5,5))
plt.subplot(2,2,1)
plt.plot(annee, prix_ws, label='Prix des windows',c='r')
plt.subplot(2,2,2)
plt.plot(annee, prix_apple, label='Prix des apples', c='g')
plt.subplot(2,2,3)
plt.plot(annee, prix_apple, label='Prix des apples', c='b')
plt.subplot(2,2,4)
plt.plot(annee, prix_apple, label='Prix des apples', c='y')
Out[96]: [<matplotlib.lines.Line2D at 0x23287c68d90>]
6 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
In [130]: index_annee=np.arange(len(annee))
a=0.5
plt.figure(figsize=(5,3))
plt.bar(index_annee, prix_ws, label='Prix des windows',width=0.5)
plt.bar(index_annee+a, prix_apple, label='prix_apple',width=0.5)
plt.xlabel('Année de vente')
plt.ylabel('Prix des appareils')
plt.legend()
plt.savefig('bargraphe.jpg')
plt.title("Variation du prix de vente en fonction de l'année")
Out[130]: Text(0.5, 1.0, "Variation du prix de vente en fonction de l'année")
In [ ]:
In [ ]:
7 sur 8 09/05/2025, 19:02
init_matplotlib - Jupyter Notebook http://localhost:8888/notebooks/ClubIA/Stage/init_matplotlib.ipynb
8 sur 8 09/05/2025, 19:02