[matplotlib-devel] Question on 3D surface plotting From: - 2006-06-19 06:37:55 Attachments: Message as HTML ```Hi - this is my first post to such a list, so bear with me.=20 =20 I've just installed mpl3d and have had success with the examples shown = at http://www.scipy.org/Cookbook/Matplotlib/mplot3D =20 We currently don't have numpy installed and using the older Numeric, so = I used the following instead: =20 N =3D 100 x =3D zeros((N,N),Float) y =3D zeros((N,N),Float) z =3D zeros((N,N),Float) u =3D arange(0,2*pi,2.*pi/N) v =3D arange(0,2*pi,2.*pi/N) =20 for i in range(N): for j in range(N): x[i,j] =3D cos(u[i])*sin(v[j]) y[i,j] =3D sin(u[i])*sin(v[j]) z[i,j] =3D cos(v[j]) =20 fig=3Dp.figure() ax =3D 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() =20 which worked a treat (apart from the figure not closing on the first = instance ...). =20 However, if I change N to 10, I get the following error message: =20 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 =3D normalize(min(shade),max(shade)) ValueError: min() arg is an empty sequence =20 It seems that if the number of columns or rows is less than 20 than = rstride and cstride =3D 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 =3D 10 (but these plots = aren't quite as nice as the surface plot would be). =20 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. =20 Cheers, Jane. =20 Dr Jane Sexton Risk Research Group Geospatial and Earth Monitoring Division Geoscience Australia ```