(cmap, badcolor="gray", bgcolor="white")
return newcm
Create a new colormap with specified bad/background colors.

    Parameters
    ----------
    cmap : string or matplotlib.colors.Colormap
        type of colormap to create
    badcolor : string
        color for bad pixels (passed to set_bad)
    bgcolor : string
        color for background (passed to set_under)
Create a new colormap with specified bad/background colors.
Create a new colormap with specified bad / background colors .
def create_colormap(cmap, badcolor="gray", bgcolor="white"):
    """Create a new colormap with specified bad/background colors.

    Parameters
    ----------
    cmap : string or matplotlib.colors.Colormap
        type of colormap to create
    badcolor : string
        color for bad pixels (passed to set_bad)
    bgcolor : string
        color for background (passed to set_under)
    """
    if type(cmap) == str:
        cmap0 = matplotlib.cm.get_cmap(cmap)
    elif type(cmap) in [
        matplotlib.colors.LinearSegmentedColormap,
        matplotlib.colors.ListedColormap,
    ]:
        cmap0 = cmap
    else:
        cmap0 = matplotlib.cm.get_cmap(matplotlib.rcParams["image.cmap"])
    if hasattr(cmap0, "_segmentdata"):
        newcm = matplotlib.colors.LinearSegmentedColormap(
            "newcm", cmap0._segmentdata, cmap0.N
        )
    else:
        newcm = copy.copy(cmap0)
    newcm.set_over(newcm(1.0))
    newcm.set_under(bgcolor)
    newcm.set_bad(badcolor)
    return newcm
def create_colormap ( cmap , badcolor = "gray" , bgcolor = "white" ) : if type ( cmap ) == str : cmap0 = matplotlib . cm . get_cmap ( cmap ) elif type ( cmap ) in [ matplotlib . colors . LinearSegmentedColormap , matplotlib . colors . ListedColormap , ] : cmap0 = cmap else : cmap0 = matplotlib . cm . get_cmap ( matplotlib . rcParams [ "image.cmap" ] ) if hasattr ( cmap0 , "_segmentdata" ) : newcm = matplotlib . colors . LinearSegmentedColormap ( "newcm" , cmap0 . _segmentdata , cmap0 . N ) else : newcm = copy . copy ( cmap0 ) newcm . set_over ( newcm ( 1.0 ) ) newcm . set_under ( bgcolor ) newcm . set_bad ( badcolor ) return newcm