import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,5,20)
y=np.exp(x)
#---------------------------------------------------------------
plt.figure(figsize = (6,4)) # DEBUT du cycle de vie de la figure
plt.plot(x,y,label='exp(x)') # j'ajoute une courbe
plt.plot(x,2*y,label='2*exp(x)') # j'ajoute une autre courbe
plt.xlabel('axe des x')
plt.ylabel('axe des y')
plt.title('y=exp(x)')
plt.legend()
plt.savefig('trace_1.png')
plt.show() # AFFICHAGE ET FIN du cycle de vie de la figure
#---------------------------------------------------------------
# Subplot
# (2,2,1) (2,2,2) # lignes colonnes position
# (2,2,3) (2,2,4)
plt.figure()
plt.subplot(2,1,1) # 2 ligne 1 colonne, position 1
plt.plot(x,y,c ='orange')
plt.subplot(2,1,2) # 2 ligne 1 colonne, position 2
plt.plot(x,y,c ='blue')
plt.show()
plt.scatter(x,y) # Nuage de points
plt.show()
# Modification du Style
plt.plot(x,y,label='courbe', lw=5, ls='--', c='green') # lw : line width , ls : line style
plt.show()