(color='red', alpha=1.)
return ListedColormap([transparent_code, color_code])
Construct a binary colormap.
Construct a binary colormap.
Construct a binary colormap .
def binary_cmap(color='red', alpha=1.):
    """Construct a binary colormap."""
    if color == 'red':
        color_code = (1., 0., 0., alpha)
    elif color == 'green':
        color_code = (0., 1., 0., alpha)
    elif color == 'blue':
        color_code = (0., 0., 1., alpha)
    else:
        color_code = color
    transparent_code = (1., 1., 1., 0.)
    return ListedColormap([transparent_code, color_code])
def binary_cmap ( color = 'red' , alpha = 1. ) : if color == 'red' : color_code = ( 1. , 0. , 0. , alpha ) elif color == 'green' : color_code = ( 0. , 1. , 0. , alpha ) elif color == 'blue' : color_code = ( 0. , 0. , 1. , alpha ) else : color_code = color transparent_code = ( 1. , 1. , 1. , 0. ) return ListedColormap ( [ transparent_code , color_code ] )