Question

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?

Was it helpful?

Solution

from mayavi.core import lut_manager

def is_tvtk_cmap(name): return name in lut_manager.lut_mode_list()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top