问题
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