I'm trying to create a figure of particle distribution from a reference surface in python. I plan to get a distribution in python and then prettify it with tikz. I tried this:xs = np.linspace(-1, 1, 10)ys = np.linspace(-1, 1, 10)X, Y = np.meshgrid(xs, ys)Z = Xfor i in range (0, 10):  for j in range (0, 10):    Z[i][j] = 0xs = randomrange(10, -1, 1)ys = randomrange(10, -1, 1)zs = randomrange(10, 0, 10)ax.plot_surface(X, Y, Z)ax.scatter(xs, ys, zs)However, I get a single line with an error message:/usr/lib/python3.2/site-packages/mpl_toolkits/mplot3d/axes3d.py:1478:  RuntimeWarning: nvalid value encountered in true_divide for n in  normals])I assume that this is due to division by 0 (trying to color the surface). How can I generate a reference surface then?Edit:I tried MRocklin's solution and replacedZ = X with Z = np.zeros_like(X)Now I don't get any surface at all...
creating a flat surface in python
python
In the line Z = XYou're just renaming X to Z, not making a copy. Your code then proceeds to zero out all elements of X. You might want to try replacing this with the following:Z = X.copy()Actually, the first bit of your code could be replaced withX, Y = np.mgrid[-1:1:10j, -1:1:10j]Z = np.zeros_like(X)Here is the full Python code to produce a flat surface using the mpl toolkit mplot3d running python 2.7.2 from the EPD academic distribution 7.1-2$ ipython --pylabIn [1]: from mpl_toolkits import mplot3dIn [2]: f = figure()In [3]: ax = mplot3d.Axes3D(f)In [4]: X, Y = mgrid[-1:1:10j, -1:1:10j]In [5]: Z = zeros_like(X)In [6]: ax.plot_surface(X,Y,Z)/home/mrocklin/Software/epd/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py:777: RuntimeWarning: invalid value encountered in divide  n = n / proj3d.mod(n)Out[6]: <mpl_toolkits.mplot3d.art3d.Poly3DCollection at 0xaa13d2c>In [7]: show()