From: Warren W. <war...@en...> - 2011-03-28 00:48:20
|
I'm using matplotlib 1.0.1. I have the following simple script to plot a surface: ----- from numpy import linspace, sin, cos, meshgrid from matplotlib.pyplot import figure, show, xlabel, ylabel from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D n = 35 x = linspace(-5, 5, n) y = linspace(0, 10, n) X, Y = meshgrid(x, y) Z = X*sin(X)*cos(0.25*Y) fig = figure() ax = fig.gca(projection='3d') ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.copper) xlabel('x') ylabel('y') show() ----- It works fine--many thanks to all the folks working on the 3D plots! But notice that Axes3D is imported from matplotlib.mplot3d, but never explicitly used. If I comment out that import, however, I get the following traceback: ----- Traceback (most recent call last): File "surf_demo.py", line 15, in <module> ax = fig.gca(projection='3d') File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/figure.py", line 965, in gca return self.add_subplot(111, **kwargs) File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/figure.py", line 675, in add_subplot projection_class = get_projection_class(projection) File "/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/site-packages/matplotlib/projections/__init__.py", line 61, in get_projection_class raise ValueError("Unknown projection '%s'" % projection) ValueError: Unknown projection '3d' ----- Is this expected? Warren |