在mlab中反转颜色映射表

4 投票
2 回答
2046 浏览
提问于 2025-04-17 15:32

我只是想知道在mlab中怎么反转一个颜色图。 我知道在matplotlib中,你只需要在颜色图的名字后面加上_r,就可以反转颜色方案了。不过在mlab中似乎有点不同。有没有人知道怎么做到这一点?

2 个回答

12

通过使用mayavi管道的脚本录制功能,我发现:

s.module_manager.scalar_lut_manager.reverse_lut = True
3

我想你是想要反转一个颜色映射表吧。下面是我用的方法(可能不是最简单的解决方案,我对mayavi不是很专业),这个方法是从这里修改过来的。

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()

撰写回答