title: Plotting a imshow() image in 3d in matplotlib
body: <p>How to plot a <code>imshow()</code> image in 3d axes? I was trying with this <a href="https://stackoverflow.com/a/25295272/4920782">post</a>. In that post, the surface plot looks same as <code>imshow()</code> plot but actually they are not. To demonstrate, here I took different data:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from mpl_toolkits.mplot3d import Axes3D
  import numpy as np
  
  # create a 21 x 21 vertex mesh
  xx, yy = np.meshgrid(np.linspace(0,1,21), np.linspace(0,1,21))
  
  # create vertices for a rotated mesh (3D rotation matrix)
  X =  xx 
  Y =  yy
  Z =  10*np.ones(X.shape)
  
  # create some dummy data (20 x 20) for the image
  data = np.cos(xx) * np.cos(xx) + np.sin(yy) * np.sin(yy)
  
  # create the figure
  fig = plt.figure()
  
  # show the reference image
  ax1 = fig.add_subplot(121)
  ax1.imshow(data, cmap=plt.cm.BrBG, interpolation='nearest', origin='lower', extent=[0,1,0,1])
  
  # show the 3D rotated projection
  ax2 = fig.add_subplot(122, projection='3d')
  ax2.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=plt.cm.BrBG(data), shade=False)
  </code></pre>
  
  <p>Here are my plots:</p>
  
  <p><img src="https://i.stack.imgur.com/wWmwH.png" alt="http://www.physics.iitm.ac.in/~raj/imshow_plot_surface.png"></p>