2

I have an application built on Mayavi where I let the user specify a colormap for some data. Because newer versions of Matplotlib have colormaps that Mayavi lacks, I'd like to be able to either use the native Mayavi colormap or make a lookuptable based on the Matplotlib colormap, if Mayavi doesn't offer it.

I could try and use the user-supplied name and catch the TraitError that is raised, but I'd rather just check the supplied name against an existing list of colors. For example, in Matplotlib I would do

import matplotlib.pyplot as plt

def is_mpl_cmap(name):
    if name in dir(plt.cm):
        return True
    return False

Is there a similar repository of colormap names in Mayavi that I could access?

4

1 回答 1

3
from mayavi.core import lut_manager

def is_tvtk_cmap(name): return name in lut_manager.lut_mode_list()
于 2013-10-31T14:04:24.693 回答