From: Raj K. M. <raj...@gm...> - 2015-05-26 16:36:58
|
Hi, How to plot a imshow() image in 3d axes? I was trying with this post <http://stackoverflow.com/a/25295272/4920782>. In that post, the surface plot looks same as imshow() plot but actually they are not. To demonstrate, here I took different data: 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) The plots are here <http://www.physics.iitm.ac.in/%7Eraj/imshow_plot_surface.png>. Is there any other way to solve this issue? I have posted this question <http://stackoverflow.com/questions/30464117/plotting-a-imshow-image-in-3d-in-matplotlib> on stackoverflow. Thanks Raj -- ################################################################## Raj Kumar Manna Complex Fluid & Biological Physics Lab IIT Madras Ph. No. 8144637401 alternate email: ra...@ph... <raj...@gm...> #################################################################### |