0

I have a 3D array of scalars representing different physical elements of a mesh, i.e. solid, liquid, or a different material of solid. I'd like to set scalars equal to 1 to be [0,1,1], scalars equal to 2 to [0,1,0], and scalars equal to 3 equal to [1, .67, 1]. I'm not sure how to define a custom colormap based on a scalar field, i.e. each scalar value in the array being associated with a specific color.

import mayavi.mlab as ml
def visualize(self):
        if len(self.geo) == 0:
            self.create_geo()
        ml.contour3d(self.geo, transparent = True)
        ml.gcf().scene.parallel_projection = True
        ml.show()
MathShark
  • 1
  • 1
  • Please elaborate on what you have tried so far to solve the presented problem. – Mike_H Aug 28 '22 at 02:16
  • So far I've looked into the custom colormap documentation, which seems related, but the documentation doesn't seem to apply to what I'm trying to do. – MathShark Aug 29 '22 at 16:05
  • https://stackoverflow.com/questions/26428645/mayavi-mapping-a-discrete-colorbar-on-a-surface This solved it for me. – MathShark Aug 29 '22 at 19:44
  • Does this answer your question? [mayavi mapping a discrete colorbar on a surface](https://stackoverflow.com/questions/26428645/mayavi-mapping-a-discrete-colorbar-on-a-surface) – Mike_H Sep 01 '22 at 00:04

0 Answers0