Exemplo n.º 1
0
def colorbar(cmap="jet", cm_min=0, cm_max=1):
    if isinstance(cmap, str):
        cmap = cmget_cmap(cmap)
    norm = matplotlibpyplotNormalize(cm_min, cm_max)
    mappable = cmScalarMappable(cmap=cmap, norm=norm)
    mappable._A = []
    return cmap, norm, mappable
Exemplo n.º 2
0
def colorbar(cmap="jet", cm_bounds=(0, 1)):
    """
    cmap, norm, mappable = colorbar('jet', min, max)
    plt.scatter(x, y, c, cmap=cmap, norm=norm)
    cb = plt.colorbar(mappable)
    if arr is given, forces cm_min and cm_max to min-max of the arr
    """
    if isinstance(cmap, str):
        cmap = mat.cm.get_cmap(cmap)
    cmin, cmax = list(map(float, cm_bounds[:2]))
    norm = matplotlibpyplotNormalize(cmin, cmax)
    mappable = mat.cm.ScalarMappable(cmap=cmap, norm=norm)
    mappable._A = []
    return cmap, norm, mappable
Exemplo n.º 3
0
def cm_bounds_to_norm(cm_bounds, data=None):
    cmin = float(cm_bounds[0]) if cm_bounds[0] is not None \
               else (np.min(data) if data is not None else 0)
    cmax = float(cm_bounds[1]) if cm_bounds[1] is not None \
               else (np.max(data) if data is not None else cmin+1)
    return matplotlibpyplotNormalize(cmin, cmax)
Exemplo n.º 4
0
def colorbar(cmap="jet", cm_min=0, cm_max=1):
    cmap = cm.get_cmap(cmap)
    norm = matplotlibpyplotNormalize(cm_min, cm_max)
    mappable = cm.ScalarMappable(cmap=cmap, norm=norm)
    mappable._A = []
    return cmap, norm, mappable