title: Finding x and y values corresponding to given z value in 3D numpy object
body: <p>I have a <code>numpy</code> object in Python (<code>np</code>) with which I am plotting a graph in <code>pyplot</code>. 
  It is a 3D graph with <code>x</code>, <code>y</code> and <code>z</code> being lists containing the values for which the graph is to be plotted.
  <a href="https://i.stack.imgur.com/9bu1z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9bu1z.png" alt="&lt;code&gt;pyplot&lt;/code&gt; chart I am getting"></a>
  Below is my code (from <a href="https://gist.github.com/amroamroamro/1db8d69b4b65e8bc66a6" rel="nofollow noreferrer">here</a>):</p>
  
  <pre><code>data = np.c_[x,y,z]
  
  # regular grid covering the domain of the data
  mn = np.min(data, axis=0) - 0.009
  mx = np.max(data, axis=0) + 0.009
  
  X,Y = np.meshgrid(np.linspace(mn[0], mx[0]), np.linspace(mn[1], mx[1]))
  XX = X.flatten()
  YY = Y.flatten()
  A = np.c_[np.ones(data.shape[0]), data[:, :2], np.prod(data[:, :2], axis=1), data[:, :2] ** 2]
  C, _, _, _ = scipy.linalg.lstsq(A, data[:, 2])
  
  # evaluate it on a grid
  Z = np.dot(np.c_[np.ones(XX.shape), XX, YY, XX * YY, XX ** 2, YY ** 2], C).reshape(X.shape)
  fig = plt.figure()
  ax = fig.gca(projection='3d')
  ax.plot_surface(X, Y, Z, rstride=1, cstride=1, alpha=0.2)
  ax.scatter(data[:, 0], data[:, 1], data[:, 2], c='r', s=50)
  plt.xlabel('X')
  plt.ylabel('Y')
  ax.set_zlabel('Z')
  ax.axis('equal')
  ax.axis('tight')
  plt.show()
  </code></pre>
  
  <p>So here, I want to get the values of <code>x</code> and <code>y</code>, where the value of <code>z</code> is closest to <code>-30</code>. How do I get those values of <code>x</code> and <code>y</code>.</p>