title: python xyz data transformation for surface plot
body: <p>I want to plot a 3D surface in matplotlib from xy and z data. For this I need to do a seemingly simple data transformation but I am unsure on how to proceed.</p>
  
  <p>My x and y data are uniform integers because it will be the surface of an image. 
  My data is present in the form of a 512x512 numpy array. The values of the array are the z values, and the indexes are the x and y values respectively.</p>
  
  <p>So if <code>arr</code> is my array, <code>arr[x, y]</code> would give my <code>z</code>. The form just looks like this:</p>
  
  <pre><code>z z z z ... z (512 columns)
  z z z z ... z
  z z z z ... z
  z z z z ... z
  . . . .
  . . . .
  z z z z (512 rows)
  </code></pre>
  
  <p>How do I get my data in the form of three columns x, y, z so I can do the surface plot? It should look like this after the transform:</p>
  
  <pre><code>  x | y | z
    ---------
    0 | 0 | z
    1 | 0 | z
    2 | 0 | z
    . | . | .
    . | . | .
  511 | 0 | z
    0 | 1 | z
    1 | 1 | z
    2 | 1 | z
    . | . | .
    . | . | .
  </code></pre>
  
  <p>I tried to work with <code>np.meshgrid</code> and <code>np.flatten</code> but can't get it to work the way I want. Maybe theres an even easier pandas solution to this. Or maybe I can even plot it with the original form of the data?</p>
  
  <p>Any suggestion is appreciated :)</p>