Welcome, guest | Sign In | My Account | Store | Cart
Python, 27 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Author: Alex Baker
# Description: fixed version of the routine from the web
# Date : 2 Apr 2008

from numpy import *	# for outer and arange
import pylab as p	# for figure
import matplotlib.axes3d as p3	# 3D axes class

fig = p.figure()	
ax = p3.Axes3D(fig)	

theta = arange(0,pi,pi/10)	
phi = arange(0,2*pi,pi/10)	
r = 2 * pow(math.e, -((theta**4)/(0.25**2))) # need to distort the radius by some function

x = r*outer(cos(phi), sin(theta))	
y = r*outer(sin(phi), sin(theta))
z = r*outer(ones(phi.shape), cos(theta))	

print shape(x), shape(y), shape(z)

ax.plot_wireframe(x,y,z)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")

p.show()

1 comment

George French 15 years, 7 months ago  # | flag

You will need the older version of the matplotlib 0.91.x

raise NotImplmentedError('axes3d is not supported in matplotlib-0.98. You may want to try the 0.91.x maintenance branch')