2016-06-20 6 views
1

나는 파이썬으로 작업하고 있으며, 그래프의 한쪽 가장자리에 삼각형을 유지하지만 실제로는 짜증나는 matraphotlib을 사용하여 3D 그래프를 만듭니다. plot_trisurf 솔루션을 찾았지만 문제를 해결하지 못했습니다.plot_trisurf 원치 않는 삼각형

variableToDisplay='U' 

fig = plt.figure() 
ax = fig.add_subplot(111, projection='3d') 

surf = ax.plot_trisurf(X,Y,Z,cmap=cm.jet, linewidth=0.1) 
fig.colorbar(surf) 
fig.tight_layout() 
plt.show(block=False) 

결과 : enter image description here

+0

수정되지 않은 삼각형이 생성 된 점 (2,4.5)과 (5.5, 0.0001)을 삭제하려고합니까? – Serenity

+0

먼저 답변 해 주셔서 감사합니다. 당신이 그 지점을 지울 때 나타나는 새로운 삼각형이 있습니다. 그리고 것은 풍력 터빈 블레이드에서 파라 메트릭 시뮬레이션을하고 있으며,이 그래프는 시뮬레이션과 모든 점에서 자동으로 계산됩니다. 그러나 나는 삼각 측량으로 읽었지만 –

+0

이 Delaunay 삼각 측량을 사용하면 일부 삼각형을 가릴 수 있거나 새로운 삼각형 분할 방법을 정의 할 수 있습니다. –

답변

0

마침내 방법을 찾을 다음은 코드입니다. 여기서 얻어진 코드 그래프이다 변수 'isbad'4.88 그 가장자리에 삼각형이 회피 될 수 있도록 Y리스트의 거의 최대 값을 의미에서

from mpl_toolkits.mplot3d import Axes3D 
from matplotlib import cm 
from matplotlib.ticker import LinearLocator, FormatStrFormatter 
import matplotlib.pyplot as plt 
import numpy as np 
import matplotlib.tri as tri 
from matplotlib.ticker import MaxNLocator 
import os 


isbad =np.greater(y, 4.88) 
triang = tr.Triangulation(x, y) 
mask = np.all(np.where(isbad[triang.triangles], True, False), axis=1) 
triang.set_mask(mask) 

fig = plt.figure() 
ax = fig.add_subplot(111, projection='3d') 
surf = ax.plot_trisurf(triang,Z,cmap=cm.jet, linewidth=0.1) 
fig.colorbar(surf) 
fig.tight_layout() 
ax.set_xlabel('Position of debond (% of blade length)') 
ax.set_ylabel('Size of debond') 
ax.set_zlabel(variableToDisplay) 
plt.show(block=False) 

enter image description here