title: 3D plot with Matplotlib
body: <p>I'm simply trying to plot a surface and its contour in 3D, exactly as in <a href="http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html" rel="noreferrer">this</a> example.</p>
  
  <p>This is the code I'm using to do it:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from mpl_toolkits.mplot3d import axes3d
  from matplotlib import cm
  import numpy
  
  def plot_3d_contour(x_dim, y_dim, x_steps, y_steps, scalar_field, file_path):
      fig = plt.figure()
  
      x, y = numpy.mgrid[-x_dim/2:x_dim/2:x_steps*1j, -y_dim/2:y_dim/2:y_steps*1j]
      v_min = numpy.min(scalar_field)
      v_max = nupmy.max(scalar_field)
  
      ax = fig.gca(projection='3d')
  
      cset = ax.contourf(x, y, scalar_field, zdir='z', offset=v_min, cmap=cm.coolwarm)
      cset = ax.contourf(x, y, scalar_field, zdir='x', offset=-x_dim/2-1, cmap=cm.coolwarm)
      cset = ax.contourf(x, y, scalar_field, zdir='y', offset=y_dim/2+1, cmap=cm.coolwarm)
  
      ax.plot_surface(x, y, scalar_field, rstride=10, cstride=10, alpha=0.3)
  
      ax.set_xlabel('X')
      ax.set_xlim(-x_dim/2-1, x_dim/2+1)
      ax.set_ylabel('Y')
      ax.set_ylim(-y_dim/2-1, y_dim/2+1)
      ax.set_zlabel('Z')
      ax.set_zlim(v_min, v_max)
  
      plt.savefig(file_path + '.jpg')
      plt.close()
  
  scalar_field = numpy.loadtxt('../scalar_field', delimiter=",")
  plot_3d_contour(12, 12, 100, 100, scalar_field, 'scalar_field3D')
  </code></pre>
  
  <p>However, I'm getting a weird behavior in which the a contour (<code>zdir=y</code>) is being over the surface. Besides, I'm getting a weird contour in <code>z_dir=z</code> (with a section missing):</p>
  
  <p><img src="https://i.stack.imgur.com/GlJAH.jpg" alt="enter image description here"></p>
  
  <p>I'm wondering what I'm missing. The scalar field can be found <a href="https://www.dropbox.com/sh/ped312ur604357r/AACQGloHDAy8I2C6HITFzjqza?dl=0" rel="noreferrer">here</a>.</p>