문제

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?

도움이 되었습니까?

해결책

from mayavi.core import lut_manager

def is_tvtk_cmap(name): return name in lut_manager.lut_mode_list()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top