title: Matplotlib- meshgrid
body: <p>I would like to make a surface plot for the solution of a grid. My domain ranges from [-1, 1] in both x and y directions. I understand that I need to provide 2D arrays to plot_surface(x,y,z) for x and y. However, I do not understand how to arrange this for z. </p>
  
  <p>To make things clearer, say I take a grid spacing of 3 points in each direction. I end up getting [-1, 0, 1] and [-1, 0, 1] in both the x and y directions respectively. This gives me 9 points where I need to evaluate for z. Here's what I wrote: </p>
  
  <pre><code>x = np.linspace(-1,1, 3)
  y = np.linspace(-1,1, 3)
  X,Y = np.meshgrid(x, y)
  # Remaining code uses plot_surface(X, Y, Z_approx)
  #
  </code></pre>
  
  <p>Each X and Y are 2D arrays, of length 3 each. However, my Z "approximation" has a length of 9. How do I then plot this together? </p>
  
  <p>Here's how the grid would look! </p>
  
  <blockquote>
    <p>*(-1,1) ____ *(0,1) ____ *(1,1)</p>
    
    <p>*(-1,0) ____ *(0,0) ____ *(1,0)</p>
    
    <p>*(-1,-1)____ *(0,-1)____ *(1,-1)</p>
  </blockquote>