Python matplotlib.cm 模块,register_cmap() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用matplotlib.cm.register_cmap()

项目:yt    作者:yt-project    | 项目源码 | 文件源码
def add_cmap(name, cdict):
    """
    Adds a colormap to the colormaps available in yt for this session
    """
    yt_colormaps[name] = \
        cc.LinearSegmentedColormap(name,cdict,256)
    mcm.datad[name] = cdict
    mcm.__dict__[name] = cdict
    try: # API compatibility
        mcm.register_cmap(name, yt_colormaps[name])
    except AttributeError:
        pass


# The format is as follows:
#   First number is the number at which we are defining a color breakpoint
#   Second number is the (0..1) number to interpolate to when coming *from below*
#   Third number is the (0..1) number to interpolate to when coming *from above*

# Next up is boilerplate -- the name, the colormap dict we just made, and the
# number of segments we want.  This is probably fine as is.
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def discrete_cmap(N=8):
    # define individual colors as hex values
    cpool = [ '#000000', '#00EE00', '#0000EE', '#00EEEE', '#EE0000',
              '#FFFF00', '#EE00EE', '#FFFFFF']
    cmap_i8 = col.ListedColormap(cpool[0:N], 'i8')
    cm.register_cmap(cmap=cmap_i8)

# -----------------------------------------------------------------

# build a list of residual images
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def discrete_cmap(N=8):
    # define individual colors as hex values
    cpool = [ '#000000', '#00EE00', '#0000EE', '#00EEEE', '#EE0000','#FFFF00', '#EE00EE', '#FFFFFF']
    cmap_i8 = colors.ListedColormap(cpool[0:N], 'i8')
    cm.register_cmap(cmap=cmap_i8)
    return cmap_i8
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def discrete_cmap(N=8):
    # define individual colors as hex values
    cpool = [ '#000000', '#00EE00', '#0000EE', '#00EEEE', '#EE0000',
              '#FFFF00', '#EE00EE', '#FFFFFF']
    cmap_i8 = col.ListedColormap(cpool[0:N], 'i8')
    cm.register_cmap(cmap=cmap_i8)

# -----------------------------------------------------------------

# build a list of residual images
项目:CAAPR    作者:Stargrazer82301    | 项目源码 | 文件源码
def discrete_cmap(N=8):
    # define individual colors as hex values
    cpool = [ '#000000', '#00EE00', '#0000EE', '#00EEEE', '#EE0000','#FFFF00', '#EE00EE', '#FFFFFF']
    cmap_i8 = colors.ListedColormap(cpool[0:N], 'i8')
    cm.register_cmap(cmap=cmap_i8)
    return cmap_i8
项目:colorcet    作者:bokeh    | 项目源码 | 文件源码
def register_cmap(name,cmap): pass
项目:colorcet    作者:bokeh    | 项目源码 | 文件源码
def mpl_cm(name,colorlist):
    cm[name]      = LinearSegmentedColormap.from_list(name, colorlist, N=len(colorlist))
    register_cmap("cet_"+name, cmap=cm[name])
    return cm[name]
项目:python-psignifit    作者:wichmann-lab    | 项目源码 | 文件源码
def getColorMap():
    """
       This function returns the standard University of Tuebingen Colormap. 
    """    
    midBlue = np.array([165, 30, 55])/255
    lightBlue = np.array([210, 150, 0])/255
    steps = 200

    MAP = _mcolors.LinearSegmentedColormap.from_list('Tuebingen', \
                    [midBlue, lightBlue, [1,1,1]],N = steps, gamma = 1.0) 
    _cm.register_cmap(name = 'Tuebingen', cmap = MAP)
    return MAP