... | ... | @@ -231,7 +231,7 @@ mon_champ.ajouter_shape("contour", nom="France") |
|
|
cmap, cbounds = cmap_continue(50)
|
|
|
mon_champ.trace_champ(cmap, cbounds)
|
|
|
|
|
|
**Etape 3** : lire des données (x,y,z) et les représenter par des isolignes
|
|
|
**Etape 3** : lire des données (x,y,z) et les représenter par la méthode **contour** (isolignes seules) ou **contourf** (aplats sans isolignes)
|
|
|
|
|
|
```python
|
|
|
from matplotlib import pyplot as plt
|
... | ... | @@ -241,15 +241,16 @@ cax = plt.contour(matrice) # renvoie un objet matplotlib.contour.QuadContourSet |
|
|
cbar= plt.colorbar(cax)
|
|
|
plt.show()
|
|
|
```
|
|
|
C'est à la la fois très facile, la syntaxe est concise, et très piégeux, puisqu'on se rend compte que par défaut la carte est cette fois tracée avec le point (0,0) en bas à gauche, soit **en miroir de la même information tracée avec matshow ! ! ! **
|
|
|
|
|
|
|
|
|
| x et y | _matrice de l'étape 1 représentée avec contour_ | matrice de l'étape 1 représentée avec contourf |
|
|
|
|--------|-------------------------------------------------|------------------------------------------------|
|
|
|
| non précisés |  | |
|
|
|
| non précisés |  |  |
|
|
|
| x et y = (1,2,5,10,20) |  |  |
|
|
|
| avec x et y = (1,2,5,10,20) | avec x et y = (1,2,5,10,20) | |
|
|
|
|
|
|
|
|
|
```python
|
|
|
from matplotlib import pyplot as plt
|
|
|
matrice = [[1, 2, 30, 50, 120], [21, 2, 50, 50, 90], [-1, 2, -30, 50, -120], [41, 42, 80, 50, 50], [9, 29, 39, 590, 10]]
|
|
|
x= (1,2,5,10,20)
|
|
|
y=x
|
|
|
cax = plt.contour(x,y,matrice) # renvoie un objet matplotlib.contour.QuadContourSet
|
... | ... | |