I'm trying to use mplot3d. I installed matibplot using the Ubuntu (lucid) repositories and it seems broken out-of-the-box. Any help would be appreciated.
This is the code I'm running:
from __future__ import division
from mpl_toolkits.mplot3d import Axes3D
from random import *
from scipy import *
import matplotlib.pyplot as plt
locA = mat([0,0,0])
locB = mat([2,0,0])
locC = mat([1,sqrt(3),0])
locD = mat([1,sqrt(3)/2,sqrt(3)])
startLoc = locA
points = startLoc
n = 10000
x = linspace(1,n,n)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for i in x:
j = randint(1,4)
if j < 2:
startLoc = (startLoc+locA)/2
points = concatenate((points,startLoc))
elif j < 3:
startLoc = (startLoc+locB)/2
points = concatenate((points,startLoc))
elif j < 4:
startLoc = (startLoc+locC)/2
points = concatenate((points,startLoc))
else:
startLoc = (startLoc+locD)/2
points = concatenate((points,startLoc))
ax.scatter(points[:,0],points[:,1],points[:,2])
plt.show()
And this is the error that I get:
Traceback (most recent call last):
File "triangle_random_3D.py", line 17, in <module>
ax = fig.add_subplot(111, projection='3d')
File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 677, in add_subplot
projection_class = get_projection_class(projection)
File "/usr/lib/pymodules/python2.6/matplotlib/projections/__init__.py", line 61, in get_projection_class
raise ValueError("Unknown projection '%s'" % projection)
ValueError: Unknown projection '3d'
Thanks.