Link text
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes(projection='3d')
# Surface ------------------
# Create the mesh in polar coordinates and compute corresponding Z
r0 = 5
r = np.linspace(0, r0, 50)
p = np.linspace(0, 2*np.pi, 50)
R, P = np.meshgrid(r, p)
Z = -R**2 + r0**2
# Express the mesh in the cartesian system
X, Y = R*np.cos(P), R*np.sin(P)
# Plot the surface
ax.plot_surface(X, Y, Z, linewidth=0, antialiased=False, alpha=0.2)
# Spiral -------------------
u = np.arange(0, 29, 0.1)
x = 0.17*u*np.cos(u)
y = 0.17*u*np.sin(u)
z = -(x**2 + y**2) + r0**2
# Plot spiral
ax.plot3D(x, y, z, 'r')
plt.savefig("ex397.png", dpi=100)
plt.show()