Hi – this is my first post to such a list, so bear
with me.
I’ve just installed mpl3d and have had success with
the examples shown at http://www.scipy.org/Cookbook/Matplotlib/mplot3D
We currently don’t have numpy installed and using the
older Numeric, so I used the following instead:
N = 100
x = zeros((N,N),Float)
y = zeros((N,N),Float)
z = zeros((N,N),Float)
u = arange(0,2*pi,2.*pi/N)
v = arange(0,2*pi,2.*pi/N)
for i in range(N):
for j in range(N):
x[i,j] = cos(u[i])*sin(v[j])
y[i,j] = sin(u[i])*sin(v[j])
z[i,j] = cos(v[j])
fig=p.figure()
ax = p3.Axes3D(fig)
ax.plot_surface(x,y,z)
ax.set_xlabel(‘X’)
ax.set_ylabel(‘Y’)
ax.set_zlabel(‘Z’)
fig.add_axes(ax)
p.show()
p.savefig(‘surfacetest’)
p.close()
which worked a treat (apart from the figure not closing on
the first instance …).
However, if I change N to 10, I get the following error
message:
Traceback (most recent call last):
File “test.py”, line 47, in ?
ax.plot_surface(x,y,z)
File "c:\Python24\lib\site-packages\mpl3d\mplot3d.py,
line 921, in plot_surface
norm = normalize(min(shade),max(shade))
ValueError: min() arg is an empty sequence
It seems that if the number of columns or rows is less than
20 than rstride and cstride = 0. This means that the boxes required to make the
polygons in the surface plot won’t be constructed. However, you can get a
3D plot if you use plot_wireframe or plot3D instead with N = 10 (but these
plots aren’t quite as nice as the surface plot would be).
Is there a minimum size of the arrays which plot_surface
will work on? Is there a workaround for smaller examples? I’m looking at
plotting a (smallish) number of time series solutions as a surface.
Cheers, Jane.
Dr Jane * ** * Sexton****
Risk
Research Group
Geospatial
and Earth Monitoring Division
Geoscience********Australia