Mayavi/mlab: Plot triangles with colour data per triangle, not per vertex

安稳与你 提交于 2019-12-10 21:56:44

问题


If one uses the function

triangular_mesh

one can pass a set of triangles, given as lists of indices, the vertex positions and a set of data to to assign colours to the vertices. The triangles are then coloured by interpolation between the vertex colours.

How can I assign colours triangle-wise, without any interpolation?


回答1:


This was asked on the scipy mailing list too.

You can't do it with triangular_mesh, but you can if you make a generic surface using a triangular mesh as a source.

s = mlab.pipeline.triangular_mesh_source(x,y,z,triangles)
s.data.cell_data.scalars = .... # Your data here.
surf = mlab.pipeline.surface(s)
surf.contours.filled_contours = True

http://mail.scipy.org/pipermail/numpy-discussion/2010-September/053040.html



来源:https://stackoverflow.com/questions/11928866/mayavi-mlab-plot-triangles-with-colour-data-per-triangle-not-per-vertex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!