|
From: Benjamin R. <ben...@ou...> - 2012-12-11 14:38:48
|
On Tue, Dec 11, 2012 at 8:25 AM, Degang Wu <sam...@gm...> wrote: > Hi, > > My OS is Mac OS X Lion, and the version of matplotlib is 1.2.0 from > macport. > > Now I have an 2d array > > a=array([[ 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 0. , 6.40312424, 19.02629759, 9.8488578 , > 12.16552506, 14. , 0. , 37.01351105], > [ 0. , 0. , 0. , 0. , > 6.40312424, 4.24264069, 1.41421356, 8.54400375, > 4.47213595, 31.25699922, 0. , 25.70992026], > [ 0. , 0. , 0. , 0. , > 19.02629759, 1.41421356, 17.2626765 , 31.32091953, > 24.18677324, 43.829214 , 0. , 55.14526272], > [ 0. , 0. , 0. , 0. , > 9.8488578 , 8.54400375, 31.32091953, 35.51056181, > 40.81666326, 57.27128425, 0. , 84.62860037], > [ 0. , 0. , 0. , 0. , > 12.16552506, 4.47213595, 24.18677324, 40.81666326, > 43.65775991, 74.24957912, 0. , 112.0044642 ], > [ 0. , 0. , 0. , 0. , > 14. , 31.25699922, 43.829214 , 57.27128425, > 74.24957912, 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. , > 0. , 0. , 0. , 0. ], > [ 0. , 0. , 0. , 0. , > 37.01351105, 25.70992026, 55.14526272, 84.62860037, > 112.0044642 , 0. , 0. , 0. ]]) > > first I plot it (in ipython notebook) using: > > coord_max=12 > fig = plt.figure() > ax = fig.gca(projection='3d') > x,y=np.meshgrid(np.arange(coord_max),np.arange(coord_max)) > ax.plot_wireframe(x,y,a) > > and the plot looks fine. > > but if I use plot_surface instead, the plot looks very wrong: the plot is > zero everywhere except on the boundaries. > This is because the default rstride and cstride arguments is 10, IIRC. Since your array is only 12x12, the surface plotting is barely plotting anything. Try calling: ax.plot_surface(x, y, a, rstride=1, cstride=1) I hope that helps! Ben Root |