Esempio n. 1
0
def _reverse_LSC(cmap):
    reverse = []
    k = []
    for key in cmap._segmentdata:
        k.append(key)
        channel = cmap._segmentdata[key]
        data = []
        for t in channel:
            data.append((1 - t[0], t[2], t[1]))
        reverse.append(sorted(data))
    LinearL = dict(zip(k, reverse))
    my_cmap_r = _LSC(cmap.name + '_r', LinearL)
    return my_cmap_r
Esempio n. 2
0
def _reverse_LSC(cmap):     
    reverse = []
    k = []   
    for key in cmap._segmentdata:    
        k.append(key)
        channel = cmap._segmentdata[key]
        data = []
        for t in channel:                    
            data.append((1-t[0],t[2],t[1]))            
        reverse.append(sorted(data))    
    LinearL = dict(zip(k,reverse))
    my_cmap_r = _LSC(cmap.name + '_r', LinearL) 
    return my_cmap_r
Esempio n. 3
0
def _make_diverging_colormap(i, f, m=[1,1,1], name='my_cmap'):
    '''
    Creates a three-color diverging colormap by interpolating smoothly between
    the RGB inputs. Output is a LinearSegmentedColormap from Matplotlib, which
    can be easily reversed using: cmap_r = _reverse_LSC(cmap), which is a
    function written in this module. 
    Inputs:
        i - Initial color as RGB or RGBA tuple or list
        f - Final color as RGB or RGBA tuple or list
        m - Middle color as RGB or RGBA tuple or list (default: white)
        name - optional name for colormap (does nothing?)
    Usage:
        BuGy = _make_diverging_colormap(i, f, m=[1,1,1], name='my_cmap')
    '''
    _cdict = {'red':   ((0.0, i[0], i[0]), (0.5, m[0], m[0]), (1.0, f[0], f[0])),
              'green': ((0.0, i[1], i[1]), (0.5, m[1], m[1]), (1.0, f[1], f[1])),
              'blue':  ((0.0, i[2], i[2]), (0.5, m[2], m[2]), (1.0, f[2], f[2]))}
    return _LSC(name, _cdict)
Esempio n. 4
0
def _make_diverging_colormap(i, f, m=[1,1,1], name='my_cmap'):
    '''
    Creates a three-color diverging colormap by interpolating smoothly between
    the RGB inputs. Output is a LinearSegmentedColormap from Matplotlib, which
    can be easily reversed using: cmap_r = _reverse_LSC(cmap), which is a
    function written in this module. 
    Inputs:
        i - Initial color as RGB or RGBA tuple or list
        f - Final color as RGB or RGBA tuple or list
        m - Middle color as RGB or RGBA tuple or list (default: white)
        name - optional name for colormap (does nothing?)
    Usage:
        BuGy = _make_diverging_colormap(i, f, m=[1,1,1], name='my_cmap')
    '''
    _cdict = {'red':   ((0.0, i[0], i[0]), (0.5, m[0], m[0]), (1.0, f[0], f[0])),
              'green': ((0.0, i[1], i[1]), (0.5, m[1], m[1]), (1.0, f[1], f[1])),
              'blue':  ((0.0, i[2], i[2]), (0.5, m[2], m[2]), (1.0, f[2], f[2]))}
    return _LSC(name, _cdict)
Esempio n. 5
0
cm.jackyCopper = _make_diverging_colormap([0.2, 0.1, 0], [1, 0.95, 0.6],
                                          m=[1, 0.65, 0.25],
                                          name='jackyCopper')
cm.jackyRdGy = _make_diverging_colormap([0.2, 0.2, 0.2], [0.7, 0, 0],
                                        m=[0.95, 0.95, 0.95],
                                        name='jackyRdGy')
_cdictPSD = {
    'red': ((0.00, 0.00, 0.06), (0.25, 0.21, 0.21), (0.45, 0.31, 0.31),
            (0.65, 1.00, 1.00), (1.00, 1.00, 1.00)),
    'green': ((0.00, 0.00, 0.06), (0.25, 0.24, 0.24), (0.50, 0.38, 0.38),
              (0.75, 0.83, 0.83), (1.00, 0.98, 1.00)),
    'blue': ((0.00, 0.00, 0.08), (0.25, 0.47, 0.47), (0.50, 0.33, 0.33),
             (0.75, 0.27, 0.27), (1.00, 0.95, 1.00))
}

cm.jackyPSD = _LSC('jackyPSD', _cdictPSD)
cm.jason = _make_STMView_colormap('Red_Blue.txt', name='jason')
cm.yanghe = invert_cmap(cm.defect0, name='yanghe')
cm.helix = invert_cmap(cm.cubehelix_r, name='helix')
cm.gold = invert_cmap(cm.bone_r, name='gold')
cm.als = _make_STMView_colormap('ALS.txt', name='als')
cm.hpblue = _make_diverging_colormap(
    [0, 0, 0], [0.14901960784313725, 0.5450980392156862, 0.9176470588235294])
cm.mhblue = _make_STMView_colormap('mhblue.mat', name='mhblue')

# Reverse Cmaps: Add new cmap name to the list.
cmaps = [
    cm.BuGy, cm.GnGy, cm.redblue, cm.autumn, cm.blue1, cm.blue2, cm.blue3,
    cm.defect0, cm.defect1, cm.defect2, cm.defect4, cm.gray, cm.sailingMod2,
    cm.jackyYRK, cm.jackyCopper, cm.jackyRdGy, cm.jackyPSD, cm.jason, cm.helix,
    cm.yanghe, cm.gold, cm.als, cm.hpblue, cm.mhblue
Esempio n. 6
0
                       (0.65, 1.00, 1.00),
                       (1.00, 1.00, 1.00)),

             'green': ((0.00, 0.00, 0.06),
                       (0.25, 0.24, 0.24),
                       (0.50, 0.38, 0.38),
                       (0.75, 0.83, 0.83),
                       (1.00, 0.98, 1.00)),

             'blue':  ((0.00, 0.00, 0.08),
                       (0.25, 0.47, 0.47),
                       (0.50, 0.33, 0.33),
                       (0.75, 0.27, 0.27),
                       (1.00, 0.95, 1.00))}

cm.jackyPSD = _LSC('jackyPSD', _cdictPSD)
cm.jason = _make_STMView_colormap('Red_Blue.txt', name='jason')
cm.yanghe = invert_cmap(cm.defect0, name='yanghe')
cm.helix = invert_cmap(cm.cubehelix_r, name='helix')
cm.gold = invert_cmap(cm.bone_r, name='gold')
cm.als = _make_STMView_colormap('ALS.txt', name='als')
cm.hpblue = _make_diverging_colormap([0,0,0],
        [0.14901960784313725, 0.5450980392156862, 0.9176470588235294])
cm.mhblue = _make_STMView_colormap('mhblue.mat', name='mhblue')



# Reverse Cmaps: Add new cmap name to the list. 
cmaps = [cm.BuGy, cm.GnGy, cm.redblue, cm.autumn, cm.blue1, cm.blue2, cm.blue3,
         cm.defect0, cm.defect1, cm.defect2, cm.defect4, cm.gray,
         cm.sailingMod2, cm.jackyYRK, cm.jackyCopper, cm.jackyRdGy,