sidpy/viz/plot_utils/cmap.py
def cmap_from_rgba(name, interp_vals, normalization_val):
    """
    Generates a colormap given a matlab-style interpolation table

    Parameters
    ----------
    name : String / Unicode
        Name of the desired colormap
    interp_vals : List of tuples
        Interpolation table that describes the desired color map. Each entry in the table should be described as:
        (position in the colorbar, (red, green, blue, alpha))
        The position in the color bar, red, green, blue, and alpha vary from 0 to the normalization value
    normalization_val : number
        The common maximum value for the position in the color bar, red, green, blue, and alpha

    Returns
    -------
    new_cmap : matplotlib.colors.LinearSegmentedColormap object
        desired color map
    """
    if not isinstance(name, (str, unicode)):
        raise TypeError('name should be a string')
    if not isinstance(interp_vals, (list, tuple, np.array)):
        raise TypeError('interp_vals must be a list of tuples')
    if not isinstance(normalization_val, Number):
        raise TypeError('normalization_val must be a number')

    normalization_val = np.round(1.0 * normalization_val)

    cdict = {'red': tuple([(dist / normalization_val, colors[0] / normalization_val, colors[0] / normalization_val)
                           for (dist, colors) in interp_vals][::-1]),
             'green': tuple([(dist / normalization_val, colors[1] / normalization_val, colors[1] / normalization_val)
                             for (dist, colors) in interp_vals][::-1]),
             'blue': tuple([(dist / normalization_val, colors[2] / normalization_val, colors[2] / normalization_val)
                            for (dist, colors) in interp_vals][::-1]),
             'alpha': tuple([(dist / normalization_val, colors[3] / normalization_val, colors[3] / normalization_val)
                             for (dist, colors) in interp_vals][::-1])}

    return LinearSegmentedColormap(name, cdict)

    Generates a colormap given a matlab-style interpolation table

    Parameters
    ----------
    name : String / Unicode
        Name of the desired colormap
    interp_vals : List of tuples
        Interpolation table that describes the desired color map. Each entry in the table should be described as:
        (position in the colorbar, (red, green, blue, alpha))
        The position in the color bar, red, green, blue, and alpha vary from 0 to the normalization value
    normalization_val : number
        The common maximum value for the position in the color bar, red, green, blue, and alpha

    Returns
    -------
    new_cmap : matplotlib.colors.LinearSegmentedColormap object
        desired color map
    
Generates a colormap given a matlab-style interpolation table
Parameters

name : String / Unicode
Name of the desired colormap
interp_vals : List of tuples
Interpolation table that describes the desired color map. Each entry in the table should be described as:
(position in the colorbar, (red, green, blue, alpha))
The position in the color bar, red, green, blue, and alpha vary from 0 to the normalization value
normalization_val : number
The common maximum value for the position in the color bar, red, green, blue, and alpha

Returns

new_cmap : matplotlib.colors.LinearSegmentedColormap object
desired color map
Generates a colormap given a matlab - style interpolation table Parameters name : String / Unicode Name of the desired colormap interp_vals : List of tuples Interpolation table that describes the desired color map . Each entry in the table should be described as : ( position in the colorbar ( red green blue alpha )) The position in the color bar red green blue and alpha vary from 0 to the normalization value normalization_val : number The common maximum value for the position in the color bar red green blue and alpha Returns new_cmap : matplotlib . colors . LinearSegmentedColormap object desired color map
def cmap_from_rgba(name, interp_vals, normalization_val):
    if not isinstance(name, (str, unicode)):
        raise TypeError('name should be a string')
    if not isinstance(interp_vals, (list, tuple, np.array)):
        raise TypeError('interp_vals must be a list of tuples')
    if not isinstance(normalization_val, Number):
        raise TypeError('normalization_val must be a number')
    normalization_val = np.round(1.0 * normalization_val)
    cdict = {'red': tuple([(dist / normalization_val, colors[0] / normalization_val, colors[0] / normalization_val)
                           for (dist, colors) in interp_vals][::-1]),
             'green': tuple([(dist / normalization_val, colors[1] / normalization_val, colors[1] / normalization_val)
                             for (dist, colors) in interp_vals][::-1]),
             'blue': tuple([(dist / normalization_val, colors[2] / normalization_val, colors[2] / normalization_val)
                            for (dist, colors) in interp_vals][::-1]),
             'alpha': tuple([(dist / normalization_val, colors[3] / normalization_val, colors[3] / normalization_val)
                             for (dist, colors) in interp_vals][::-1])}
    return LinearSegmentedColormap(name, cdict)
def cmap_from_rgba ( name , interp_vals , normalization_val ) : if not isinstance ( name , ( str , unicode ) ) : raise TypeError ( 'name should be a string' ) if not isinstance ( interp_vals , ( list , tuple , np . array ) ) : raise TypeError ( 'interp_vals must be a list of tuples' ) if not isinstance ( normalization_val , Number ) : raise TypeError ( 'normalization_val must be a number' ) normalization_val = np . round ( 1.0 * normalization_val ) cdict = { 'red' : tuple ( [ ( dist / normalization_val , colors [ 0 ] / normalization_val , colors [ 0 ] / normalization_val ) for ( dist , colors ) in interp_vals ] [ : : - 1 ] ) , 'green' : tuple ( [ ( dist / normalization_val , colors [ 1 ] / normalization_val , colors [ 1 ] / normalization_val ) for ( dist , colors ) in interp_vals ] [ : : - 1 ] ) , 'blue' : tuple ( [ ( dist / normalization_val , colors [ 2 ] / normalization_val , colors [ 2 ] / normalization_val ) for ( dist , colors ) in interp_vals ] [ : : - 1 ] ) , 'alpha' : tuple ( [ ( dist / normalization_val , colors [ 3 ] / normalization_val , colors [ 3 ] / normalization_val ) for ( dist , colors ) in interp_vals ] [ : : - 1 ] ) } return LinearSegmentedColormap ( name , cdict )
Generates a colormap given a matlab-style interpolation table
Parameters
Generates a colormap given a matlab - style interpolation table Parameters
"""
    Generates a colormap given a matlab-style interpolation table

    Parameters
    ----------
    name : String / Unicode
        Name of the desired colormap
    interp_vals : List of tuples
        Interpolation table that describes the desired color map. Each entry in the table should be described as:
        (position in the colorbar, (red, green, blue, alpha))
        The position in the color bar, red, green, blue, and alpha vary from 0 to the normalization value
    normalization_val : number
        The common maximum value for the position in the color bar, red, green, blue, and alpha

    Returns
    -------
    new_cmap : matplotlib.colors.LinearSegmentedColormap object
        desired color map
    """
name
interp_vals
normalization_val