Question

I simply want to know how to invert a colormap in mlab. I know in matplotlib you can simply add _r to the name of the colormap to invert the color scheme. However it appears to be slightly different in mlab. Does anyone know how this can be achieved?

Was it helpful?

Solution 2

I guess you want to reverse a colormap. Here is what works for me (it might not be the easiest solution, i am not an expert on mayavi), modified from here

s=mlab.surf(xx,yy,zz,colormap='GnBu')
lut = s.module_manager.scalar_lut_manager.lut.table.to_array()
ilut = lut[::-1]
# putting LUT back in the surface object
s.module_manager.scalar_lut_manager.lut.table = ilut
# forcing to update the figure once we have changed the LUT
mlab.draw()
mlab.view()

OTHER TIPS

Using the script recording of the mayavi pipeline, I found :

s.module_manager.scalar_lut_manager.reverse_lut = True
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top