"""
An example of ploting a parametric surface in 3D, using matplotlib 3D graphics

"""

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from numpy import pi, sin , cos
from matplotlib import cm

def f(x,y):
   return sin(x)*cos(y)

theta,phi = np.mgrid[0: 2*pi: 101j, 0:2*pi:101j]

r= 0.25

xx = -sin(theta)*(1+r*cos(phi))
yy= cos(theta)*(1+r*cos(phi))
zz = r*sin(phi)



plt.ion
fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_zlim(-1,1)



ax.plot_surface(xx,yy, zz,rstride=5, cstride=5, cmap=cm.jet,
     alpha=0.8)
ax.elev, ax.azmin = 75, 120
plt.show()
