2017-03-23 7 views
0

私は表面高さの配列を持っていますH。 サーフェスをワイヤフレームとしてプロットし、投影の一番下にpcolormeshまたはimshowという値を入れたいとします(例:z=0)。3d平面上に二色のグリッド(例えば、pcolormesh)をプロットする

import numpy as np 
import matplotlib.pyplot as plot 
from mpl_toolkits.mplot3d import Axes3D 

H=np.arange(0,100) 
H=H.reshpae(10,10) # <- just as simple example 

x,y = np.meshgrid(range(0,20),range(0,20)) 
fig=plot.figure() 
ax=fig.gca(projection='3d') 
ax.plot_wireframe(x,y,H) 
#plot 2D meshgrid here 
fig.show() 

もちろん、pcolormeshは2Dのみです。しかし、countourfを使用してもグリッドのような構造は表示されません。様々なストライドが輪郭を全く変えなかった。 私はすでにplot_surfaceの使用について考えていましたが、色を変更している間に2D投影を行う方法はわかりません。

+0

おそらく、これは非常に密接に関連していますhttp://stackoverflow.com/questions/10917495/matplotlib-imshow-in-3d-plot – ImportanceOfBeingErnest

答えて

0

平面図を使用して、imshowを模倣することができます。私。一定の値でサーフェスをプロットし、データ値に応じてサーフェスの色を設定します。

これを以下に示します。

import numpy as np 
import matplotlib.pyplot as plt 
from mpl_toolkits.mplot3d import Axes3D 
import matplotlib 

H=np.arange(0,100) 
H=H.reshape(10,10) 

x,y = np.meshgrid(range(0,10),range(0,10)) 
fig=plt.figure() 
ax=fig.gca(projection=Axes3D.name) 
ax.plot_wireframe(x,y,H) 

#plot 2D meshgrid here 
cmap = plt.cm.plasma 
norm = matplotlib.colors.Normalize(vmin=H.min(), vmax=H.max()) 
colors = cmap(norm(H)) 
ax.plot_surface(x,y,np.zeros_like(x), cstride=1, rstride=1, facecolors=colors, shade=False) 
#make a colorbar 
sc = matplotlib.cm.ScalarMappable(cmap=cmap, norm=norm) 
sc.set_array([]) 
plt.colorbar(sc) 
plt.show() 

enter image description here

関連する問題