I changed the mplot3d example code for my application using Paul. The code reads:
from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') u = np.linspace(0, 2 * np.pi, 100) v = np.linspace(0, np.pi, 100) x = 10 * np.outer(np.cos(u), np.sin(v)) y = 10 * np.outer(np.sin(u), np.sin(v)) z = 10 * np.outer(np.ones(np.size(u)), np.cos(v)) z1 = z * np.cos(0.5*x) N = z1 / z1.max()

This code is great for building a surface. But when I try to add a colorbar to the above chart, I get the following error:
Traceback (most recent call last): File "<ipython console>", line 1, in <module> File "C:\Python26\lib\site-packages\spyderlib\widgets\externalshell\startup.py", line 122, in runfile execfile(filename, glbs) File "C:\Documents and Settings\mramacha\My Documents\Python\Candela\test.py", line 22, in <module> fig.colorbar(surf, shrink=0.5, aspect=5) File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 1104, in colorbar cb = cbar.Colorbar(cax, mappable, **kw) File "C:\Python26\lib\site-packages\matplotlib\colorbar.py", line 706, in __init__ mappable.autoscale_None()
I would be so grateful if anyone could help me.
Prabhu
python matplotlib
praboo Jul 06 '11 at 17:33 2011-07-06 17:33
source share