Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
matplotlib [Le 22/03/2015, 10:08]
G-Tux créée
matplotlib [Le 11/09/2022, 11:39] (Version actuelle)
moths-art Suppression des espaces en fin de ligne (détecté et corrigé via le bot wiki-corrector (https://forum.ubuntu-fr.org/viewtopic.php?id=2067892)
Ligne 1: Ligne 1:
-{{tag>​logiciels_pour_le_lycée calcul_numérique}}+{{tag>grapheurs programmation ​logiciels_pour_le_lycée calcul_numérique ​education}}
  
 ---- ----
Ligne 5: Ligne 5:
 ====== Matplotlib ====== ====== Matplotlib ======
  
-Bibliothèque ​Python permettant de réaliser des graphiques en et 3D+**Matplotlib** est une bibliothèque ​Python permettant de réaliser des graphiques en 2D et 3D 
  
-\\  
  
 ===== Pré-requis ===== ===== Pré-requis =====
Ligne 23: Ligne 23:
 sudo apt-get install python-matplotlib</​code>​ sudo apt-get install python-matplotlib</​code>​
  
 +en python 3 : 
 +<​code>​ 
 +sudo apt-get install python3-matplotlib</​code>​
 ===== Utilisation ===== ===== Utilisation =====
  
-Exemple d'utilisation ​(tiré de [[http://​commons.wikimedia.org/​wiki/​File:​Complex_arcsin_abs_01_Pengo.svg?​uselang=fr|Wikipédia]]) ​:+Exemple d'un graphique en 2D (tiré de [[https://​commons.wikimedia.org/​wiki/​File:​Logarithmic_Spiral_Pylab.svg?​uselang=fr|Wikipédia]] ​(licence domaine public))
 Créer un fichier et y coller le code : Créer un fichier et y coller le code :
-<​file>​+<​file ​python spirale.py>​ 
 +#​!/​usr/​bin/​env python 
 +from pylab import * 
 +rc('​grid',​ color='#​aaaaaa',​ linewidth = 1, linestyle = '​-'​) 
 +figure(figsize = (6, 6)) 
 +ax = axes([0.1, 0.1, 0.8, 0.8], polar = True) 
 +t = arange(-4 * pi, 4 * pi, .1) 
 +polar(t, 1.19**t, linewidth = 2) 
 +xt, yt = xticks()[0],​ yticks()[0] 
 +xticks(xt, [''​ for q in range(len(xt))]) 
 +yticks(yt, [''​ for q in range(len(yt))]) 
 +savefig('​logarithmic_spiral.jpg'​) 
 +show()</​file>​ 
 + 
 +Sauvegarder et rendre le fichier exécutable.\\ 
 +Lancer le code, par exemple en ligne de commande :<​code>​ python spirale.py</​code>​ 
 +vous obtiendrez : 
 + 
 +{{ ::​python:​matplotlib:​logarithmic_spiral.jpg ?​direct&​200 |}} 
 + 
 +Autre exemple d'​utilisation (tiré de [[https://​commons.wikimedia.org/​wiki/​File:​Complex_arcsin_abs_01_Pengo.svg?​uselang=fr|Wikipédia]] (licence domaine public)) : 
 +Créer un fichier et y coller le code : 
 +<file python graphs.py>
 #​!/​usr/​bin/​env python #​!/​usr/​bin/​env python
    
Ligne 53: Ligne 77:
         ax.set_ylabel("​y"​)         ax.set_ylabel("​y"​)
         ax.set_zlabel(gr + '​(sin(x+iy))'​)         ax.set_zlabel(gr + '​(sin(x+iy))'​)
-        plt.savefig("​complex_arcsin_"​ + gr + "​_01_Pengo.svg")+        plt.savefig("​complex_arcsin_"​ + gr + "​_01_Pengo.jpg")
 </​file>​ </​file>​
-Sauvgarder et rendre le fichier exécutable. 
-Lancer le code, vous obtiendrez : 
  
 +Sauvegarder et rendre le fichier exécutable.
 +Lancer le code, vous obtiendrez les figures suivantes :
 +
 +{{::​python:​matplotlib:​complex_arcsin_abs_01_Pengo.jpg ?​direct&​200 |}}
 +{{ ::​python:​matplotlib:​complex_arcsin_angle_01_Pengo.jpg?​direct&​200 |}}
 +{{::​python:​matplotlib:​complex_arcsin_imag_01_Pengo.jpg ?​direct&​200 |}}
 +{{ ::​python:​matplotlib:​complex_arcsin_real_01_Pengo.jpg?​direct&​200 |}}
 +
 +===== Voir aussi =====
 +
 +  * [[https://​matplotlib.org/​|site officiel matplotlib]]
 +  * [[Gnuplot]]
 +  * [[http://​pyqtgraph.org/​|PyQtGraph]]
 +
 +----
 +
 +//​Contributeur : [[utilisateurs:​G-Tux]].//​
  • matplotlib.1427015298.txt.gz
  • Dernière modification: Le 22/03/2015, 10:08
  • par G-Tux