mayavi 不能为平面上的多边形线做 plot3d

mayavi cant do plot3d for line of polygon on plane

我有多边形坐标 x,y,z 的数据:

(现在我正确格式化了数据...)

x,y,z = [-5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386 , -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386 , -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386 , -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386 , -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386 , -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, -5.386, - 5.386,-5.386,-5.386,-5.386,-5.386,-5.386,-5.386,-5.386,-5.386],[-8.96564198,-8.91759205,-8.91759205 8.04073524, -7.29788256, -7.29788256, -7.22981453, -7.22981453, -6.48705292, -6.48705292, -6.41897631, -6.41897631, -5.67612362, -5.67612362, -5.60804701, -5.60804701, -4.8652854, -4.8652854, -4.79720879, -4.79720879, -4.0543561, -4.0543561, -3.98628807, -3.98628807, -3.24352646, -3.24352646, -3.17545009, -3.17545009, -2.43259692, -2.43259692, -2.36452055, -2.36452055, -1.62175894, -1.62175894, -1.55369115, -1.55369115, -0.8108381 , -0.8108381, -0.06807642, -0.06807642, 0.0, 0.0, 0.06844116, 0.06844116, 0.81120288, 0.81120288, 0.87964404, 0.87964404, 1.62249708, 1.62249708, 1.69094694, 1.69094694, 2.43370867, 2.43370867, 2.50214982, 2.50214982, 3.24500275, 3.24500275, 3.3134439, 3.3134439, 4.05620575, 4.05620575, 4.12464666, 4.12464666, 4.86749983, 4.86749983, 4.93594122, 4.93594122, 5.67870283, 5.67870283, 5.67870283, 5.73471 .74715233, 6.49000549, 6.49000549, 6.55844688, 6.55844688, 7.3012085, 7.3012085, 7.36964941, 7.36964941, 8.11250305, 8.11250305, 8.17483044, 8.17483044, 8.91759205, 8.91759205, 8.96564198, 8.96564198, 9.00691128, 9.00691128, 9.69999981, 9.69999981, 9.88442802, 9.88442802, 9.93230438, 9.93230438 , 10.1330328, 10.1330328, 10.10715866, 10.10715866, 10.30800629, 10.30800629, 10.31350517, 10.31350517, 10.47220325, 10.47220325, 10.47767353, 10.47767353, 10.5281105, 10.5281105, 10.53109264, 10.53109264, 10.5381422, 10.5381422, 10.53948784, 10.53948784, 10.52461624, 10.52461624, 10.52502251, 10.52502251, 10.50097942 , 10.50097942, 10.50071716, 10.50071716, 10.48459435, 10.48459435, 10.39999962, 10.39999962, 9.60570526, 9.60570526, 9.56569958, 9.56569958, 8.55252838, 8.55252838, 8.50290012, 8.50290012, 7.48804045, 7.48804045, 7.44000006, 7.44000006, 6.42374277, 6.42374277, 6.37720013, 6.37720013, 5.35944319, 5.35944319 , 5.31430006, 5.31430006, 4.29522181, 4.29522181, 4.25139999, 4.25139999, 3.231 17161, 3.23117161, 3.18860006, 3.18860006, 2.16709828, 2.16709828, 2.1257, 2.1257, 1.10318041, 1.10318041, 1.06289995, 1.06289995, 0.0392214, 0.0392214, 0.0, 0.0, -1.03653765, -1.03653765, -1.07512617, -1.07512617, -2.11073256, -2.11073256, -2.15035224, -2.15035224, -3.18478632, -3.18478632, -3.22547793, -3.22547793, -4.25886393, -4.25886393, -4.30070353, -4.30070353, -5.33279181, -5.33279181, -5.37582827, -5.37582827, -6.40673113, -6.40673113, -6.45105314 , -6.45105314, -7.48050976, -7.48050976, -7.52618217, -7.52618217, -8.55428886, -8.55428886, -8.6014061, -8.6014061, -9.62787724, -9.62787724, -9.67652988, -9.67652988, -10.36547565, -10.36547565, -10.39999962, - 10.39999962, -10.41505051, -10.41505051, -10.52405071, -10.52405071, -10.52689934, -10.52689934, -10.53348255, -10.53348255, -10.53496647, -10.53496647, -10.55486393, -10.55486393, -10.55375099, -10.55375099, -10.56892776, -10.56892776, -10.56253052, -10.56253052, -10.56037807, -10.56037807, -10.54539394, -10.54539394, -10.507 01427, -10.50701427, -10.47525024, -10.47525024, -10.35439491, -10.35439491, -10.34592438, -10.34592438, -10.25755596, -10.25755596, -10.10438442, -10.10438442, -9.99352741, -9.99352741, -9.69999981, -9.69999981, -9.65165234, -9.65165234, -8.96564198, -8.96564198, -8.91759205],[1.74571705, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1 .74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001 , 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74667001, 1.74571705, 1.74571705, 1.75442255, 1.75442255, 1.75442255, 1.75442255, 1.82700002, 1.82700002, 1.96033335, 1.96033335, 2.36971664, 2.36971664, 2.46872306, 2.46872306, 2.93799996, 2.93799996, 3.10320163, 3.10320163, 3.97582817 , 3.97582817, 4.14201975, 4.14201975, 5.02765846, 5.02765846, 5.19697523, 5.19697523, 6.08110237, 6.08110237, 6.25430679, 6.25430679, 7.13444996, 7.13444996, 7.31143522, 7.31143522, 8.18754387, 8.18754387, 8.36124897, 8.36124897, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012 , 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.222 00012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 9.22200012, 8.99069691, 8.99069691, 8.55359173, 8.55359173, 8.16760635, 8.16760635, 7.44270992, 7.44270992, 7.05001211, 7.0500121 1, 6.30944681, 6.30944681, 5.93197727, 5.93197727, 5.17690754, 5.17690754, 4.80531073, 4.80531073, 4.04644012, 4.04644012, 3.62315774, 3.62315774, 2.93799996, 2.93799996, 2.57678986, 2.57678986, 2.37031913, 2.37031913, 2.0530901, 2.0530901, 1.82700002, 1.82700002, 1.75442255, 1.75442255, 1.74571705、1.74571705、1.74571705、1.74571705、1.74667001]

当我尝试这样做时:

import mayavi.mlab as mvi

mvi.plot3d(x,y,z)
mvi.show()

显示空白图...

但这有效并显示字形和点:

import mayavi.mlab as mvi

mvi.points3d(x,y,z)
mvi.show()

这是怎么回事?

在测试你的代码时,我有一个警告:

Generic Warning: In /build/vtk6-MXHdkt/vtk6-6.3.0+dfsg1/Common/DataModel/vtkPolyLine.cxx, line 197
Coincident points in polyline...can't compute normals

Warning: In /build/vtk6-MXHdkt/vtk6-6.3.0+dfsg1/Filters/Core/vtkTubeFilter.cxx, line 243
vtkTubeFilter (0x52e7970): Could not generate normals for line. Skipping to next.

can't compute normals可能意味着你有连续的数据点叠加。

一种解决方案是添加选项 tube_radius=None。这样,VTK 不会绘制跟随您的数据点的管,而只是用一条普通线将它们链接起来,请参阅 http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#plot3d