2017-05-29 10 views
2

matplotlibのバージョンを1.3.1から2.0.2に更新した後、plot_trisurfを使用して3DポイントでTINを生成したい場合、私は理解できない結果になります。私のテストコードは次のとおりです:matplotlibのPlot_trisurf 2.0.2

import sys 
import matplotlib 
import matplotlib.pyplot as plt 
from matplotlib.ticker import MaxNLocator 
from matplotlib import cm 
from mpl_toolkits.mplot3d import Axes3D 
import numpy 
from numpy.random import randn 
from scipy import array, newaxis 

chunk = numpy.loadtxt('test.xyz') #test.xyz contains 38010 points, 
DATA=numpy.array(chunk) 
Xs = DATA[:,0] 
Ys = DATA[:,1] 
Zs = DATA[:,2] 

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

surf = ax.plot_trisurf(Xs, Ys, Zs, cmap=cm.jet, linewidth=0) 
fig.colorbar(surf) 

ax.xaxis.set_major_locator(MaxNLocator(5)) 
ax.yaxis.set_major_locator(MaxNLocator(6)) 
ax.zaxis.set_major_locator(MaxNLocator(5)) 

fig.tight_layout() 
plt.show() 

test.xyzファイルには38010ポイントが含まれています。その一部は次のように表示されます。完全なファイルはhereです。更新後

512743.63 5403547.33 308.68 
512743.62 5403547.33 308.70 
512743.61 5403547.33 308.72 
512743.60 5403547.34 308.68 
512743.60 5403547.33 308.73 
512741.50 5403547.36 309.05 
512741.50 5403547.36 309.07 
512741.49 5403547.46 309.09 
512741.48 5403547.46 309.07 
512741.47 5403547.46 309.10 
512741.47 5403547.45 309.13 
512741.46 5403547.37 309.04 
512739.39 5403547.51 309.10 
512739.39 5403547.48 309.34 
512739.38 5403547.60 309.25 
512739.37 5403547.71 309.15 
512739.39 5403547.49 310.65 
512739.39 5403547.48 310.70 
512739.38 5403547.49 310.69 
512739.37 5403547.48 310.72 
512739.36 5403547.39 310.64 
512739.32 5403547.41 309.20 
512737.33 5403547.26 313.14 
512737.33 5403547.37 313.09 
512737.32 5403547.38 313.03 
512737.30 5403547.37 313.12 
512737.30 5403547.26 313.14 
512735.22 5403547.41 311.72 
512735.22 5403547.43 312.29 
512735.22 5403547.49 312.59 
512735.21 5403547.51 312.48 
512735.20 5403547.60 312.53 
512735.19 5403547.61 312.48 
512735.18 5403547.72 312.40 
512735.18 5403547.71 312.49 
512735.17 5403547.71 312.51 
512735.16 5403547.70 312.58 
512735.15 5403547.61 312.52 

、結果は以下のように示されている:]

私はTINを生成するために十分なポイントを提供するので、それは、間違っていると思うが、結果はポイントのほんの一部を使用しているようです。 matplotlibを更新する前に、次のような結果を得ることができます: ]

+0

あなたの返事ありがとうございますが、私は38010ポイントを含むファイルを提供しています。上記のデータはデータフォーマットを示すために非常に小さい部分を示しています – zxgao

+0

詳細は[link](https://github.com/zxgdll/problem-about-matplotlib2.0.2)に示されています – zxgao

+0

trisurfプロットは点のサブセットのみをプロットします。私はこれの理由はわかりませんが、三角測量やトリスフーフプロット自体のどこかにあるはずです。あなたが置いた[GitHubの問題](https://github.com/matplotlib/matplotlib/issues/8682)に再現可能なコードを追加しました。 – ImportanceOfBeingErnest

答えて

0

ありがとうございました。この問題は解決され、詳細はProblem about plot_trisurf of matplotlib 2.0.2に示されています。 ここに私の結果を示すのが楽しいです。 この問題は、qhullのDelaunay三角測量を計算するときに有限の精度の1つです。これは、近くにある点(「近く」という複雑な定義に従う)が同じであるとみなし、三角測量が必要以上に簡単です。データセットは、その平均に関する点の広がりが小さい(x.mean()= 512767、x.max() - x.min()= 134、yであるという点で、有限精度の極端なものです.mean()= 303、y.max() - y.min()= 5403707)。これはIan Thomasによって説明されました。

import sys 
import matplotlib 
import matplotlib.pyplot as plt 
from matplotlib.ticker import MaxNLocator 
from matplotlib import cm 
from mpl_toolkits.mplot3d import Axes3D 
import numpy 
from numpy.random import randn 
from scipy import array, newaxis 

chunk = numpy.loadtxt('test.xyz') #test.xyz contains 38010 points, 
DATA=numpy.array(chunk) 
Xs = DATA[:,0] 
Ys = DATA[:,1] 
Zs = DATA[:,2] 

fig = plt.figure() 
ax = fig.add_subplot(111, projection='3d') 
#surf = ax.plot_trisurf(Xs, Ys, Zs, cmap=cm.jet, linewidth=0) 
surf = ax.plot_trisurf(Xs-Xs.mean(), Ys-Ys.mean(), Zs, cmap=cm.jet, linewidth=0) 
fig.colorbar(surf) 

ax.xaxis.set_major_locator(MaxNLocator(5)) 
ax.yaxis.set_major_locator(MaxNLocator(6)) 
ax.zaxis.set_major_locator(MaxNLocator(5)) 

fig.tight_layout() 
plt.show() 

結果は以下のように示された、前に::だから合計に enter image description here

:結果は以下のように示された、後 enter image description here

次のようにこのように、私は私のテストコードを修正した これは実際には異なるmatplotlibバージョン間の問題ではなく、現在のバージョンは大部分のユースケースに対処するのに十分です。そして、軸チックラーブが簡単に訂正されることを望む人は、ImportanceOfBeingErnestのmethod.

関連する問題