0
AFAIK Mayavi不具有任何感知上均匀的颜色映射。我试过天真地只是通过它one of Matplotlib's colormaps但它失败:在Mayavi体积可视化中使用感知均匀的颜色图
from mayavi import mlab
import multiprocessing
import matplotlib.pyplot as plt
plasma = plt.get_cmap('plasma')
...
mlab.pipeline.volume(..., colormap=plasma)
TraitError: Cannot set the undefined 'colormap' attribute of a 'VolumeFactory' object.
编辑:我发现a guide转换Matplotlib色彩映射到Mayavi的颜色表。但是,由于我试图使用感知上统一的色彩映射来使用卷,所以它不起作用。
from matplotlib.cm import get_cmap
import numpy as np
from mayavi import mlab
values = np.linspace(0., 1., 256)
lut_dict = {}
lut_dict['plasma'] = get_cmap('plasma')(values.copy())
x, y, z = np.ogrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(x*y*z)/(x*y*z)
mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=0, vmax=0.8, colormap=lut_dict['plasma']) # still getting the same error
mlab.axes()
mlab.show()
...
发现了类似的问题在这里:https://stackoverflow.com/questions/26970659/scalar-fields-visualisation-in-python – crypdick
据我所知,这似乎是一个错误。我在这里提交了一个错误报告:https://github.com/enthought/mayavi/issues/371 – crypdick