def create_cmap(): ### Create a list of RGB tuples colors = [(229, 229, 229), (182, 165, 134), (160, 138, 91), (138, 111, 49), (140, 127, 43), (142, 143, 37), (144, 159, 31), (146, 175, 25), (138, 177, 21), (119, 165, 18), (99, 154, 15), (80, 142, 12), (60, 131, 9), (41, 119, 6), (22, 108, 3), (3, 97, 0), (0, 23, 0)] # This example uses the 8-bit RGB ### Create an array or list of positions from 0 to 1. position = [0, 0.04, 0.08, 0.12, 0.16, 0.20, 0.24, 0.28, 0.32, 0.36, 0.40, 0.44, 0.48, 0.52, 0.56, 0.60, 1] evi_cmap = make_cmap(colors, position=position, bit=True) cm.register_cmap(name='evi', cmap=evi_cmap) EVI = cm.get_cmap('evi') export_colormap('evi_colorbar',evi_cmap) return EVI
def getColor(options, i, a): if options.colors: v = options.colors.split(",") if i >= len(v): raise Exception("Error: not enough colors given") return v[i] if options.colormap[0] == '#': colormap = parseColorMap(options.colormap[1:]) cm.register_cmap(name="CUSTOM", cmap=colormap) options.colormap = "CUSTOM" colormap = get_cmap(options.colormap) # cm = options.colormap# get_cmap(options.colormap) cNorm = matplotlib.colors.Normalize(vmin=0, vmax=a) scalarMap = matplotlib.cm.ScalarMappable(norm=cNorm, cmap=colormap) return scalarMap.to_rgba(i)
def getColor(options, i, a): if options.colors: v = options.colors.split(",") if i >= len(v): print("Error: not enough colors given") sys.exit(1) return v[i] if options.colormap[0] == '#': colormap = parseColorMap(options.colormap[1:]) cm.register_cmap(name="CUSTOM", cmap=colormap) options.colormap = "CUSTOM" colormap = get_cmap(options.colormap) # cm = options.colormap# get_cmap(options.colormap) cNorm = matplotlib.colors.Normalize(vmin=0, vmax=a) scalarMap = matplotlib.cm.ScalarMappable(norm=cNorm, cmap=colormap) return scalarMap.to_rgba(i)
def create_cmap(): ### Create a list of RGB tuples colors = [(229, 229, 229), (182, 165, 134), (160, 138, 91), (138, 111, 49), (140, 127, 43), (142, 143, 37), (144, 159, 31), (146, 175, 25), (138, 177, 21), (119, 165, 18), (99, 154, 15), (80, 142, 12), (60, 131, 9), (41, 119, 6), (22, 108, 3), (3, 97, 0), (0, 23, 0)] # This example uses the 8-bit RGB ### Create an array or list of positions from 0 to 1. position = [ 0, 0.04, 0.08, 0.12, 0.16, 0.20, 0.24, 0.28, 0.32, 0.36, 0.40, 0.44, 0.48, 0.52, 0.56, 0.60, 1 ] evi_cmap = make_cmap(colors, position=position, bit=True) cm.register_cmap(name='evi', cmap=evi_cmap) EVI = cm.get_cmap('evi') export_colormap('evi_colorbar', evi_cmap) return EVI