import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D 
from matplotlib.ticker import LinearLocator, FormatStrFormatter 
#Un premier graphe de surface
x=np.arange(-2,2,0.01)
y=np.arange(-1,1,0.05)
x,y=np.meshgrid(x,y)
z=x**2+y**2
fig=plt.figure(1) #Declaration de la figure
plt.clf() #nettoyage de la figure
ax = fig.add_subplot(111, projection='3d') #creation du plot 
surf=ax.plot_surface(x,y,z, cmap='hot', linewidth=0, cstride=1, rstride=1, alpha=0.8, antialiased=False) 
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_title('Graphe de surface')
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
# Parametrage de surfaces
theta=np.arange(-np.pi,np.pi,0.01)
phi=np.arange(0.0,2*np.pi,0.05)
theta,phi=np.meshgrid(theta,phi)
x=np.cos(theta)*np.sin(phi)
y=np.sin(theta)*np.sin(phi)
z=np.cos(phi)
fig=plt.figure(2) #Declaration de la figure
plt.clf() #nettoyage de la figure
ax = fig.add_subplot(111, projection='3d') #creation du plot 
surf=ax.plot_surface(x,y,z, cmap='hot', linewidth=0, cstride=1, rstride=1, alpha=0.8, antialiased=False) 
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_title('Graphe de surface')
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
