4

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?

Community
  • 1
  • 1
user1750948
  • 719
  • 2
  • 10
  • 27

2 Answers2

12

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

s.module_manager.scalar_lut_manager.reverse_lut = True
recursix
  • 333
  • 2
  • 9
3

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()
sangita
  • 74
  • 3