2017-05-16 1 views
0

축을 표시하지만 축 사이의면을 표시하지 않는 3D 표면 플롯을 만들고 싶습니다. 내가 찾은 것은 축뿐만 아니라 ax.set_axis_off()을 사용하여 얼굴을 끄는 방법입니다. 그 얼굴 만 끄거나 투명하게 만들 기회가 있습니까? 사전에 With axes and background Without axes and backgroundMatplotlip : 3D 표면 플롯 플롯 배경이 꺼져 있지만 축을 유지합니다.

감사를 (당신이 자세히 보면 첫 번째 사진에서는 얼굴을 볼 수 있습니다)!

+0

참조 http://stackoverflow.com/questions/11448972/changing-the-background-color-of-the-axes-planes -of-a-matplotlib-3d-plot – ImportanceOfBeingErnest

답변

1

"창을 끈"수는 없지만 색을 변경하여 투명하게 만들 수 있습니다.

ax.xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0)) 

전체 코드 :

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

fig = plt.figure() 
ax = fig.gca(projection='3d') 
ax.set_xlabel("x"); ax.set_ylabel("y"); ax.set_zlabel("z") 

x = np.arange(-5, 5, 0.25) 
X, Y = np.meshgrid(x,x) 
Z = np.sin(np.sqrt(X**2 + Y**2)) 

# make the panes transparent 
ax.xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0)) 
ax.yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0)) 
ax.zaxis.set_pane_color((1.0, 1.0, 1.0, 0.0)) 
# make the grid lines transparent 
ax.xaxis._axinfo["grid"]['color'] = (1,1,1,0) 
ax.yaxis._axinfo["grid"]['color'] = (1,1,1,0) 
ax.zaxis._axinfo["grid"]['color'] = (1,1,1,0) 

surf = ax.plot_surface(X, Y, Z, cmap=plt.cm.coolwarm, 
        linewidth=0, antialiased=False) 

fig.colorbar(surf, shrink=0.5, aspect=5) 
plt.show() 
또한

enter image description here