def mpl_color(plotly_color):
    """
    Convert a plotly color name to a matplotlib compatible one.

    Parameters
    ----------
    plotly_color : str
        A plotly color value, e.g. `"#FF0023"` or `"rgb(0,255,128)"`.

    Returns
    -------
    str
    """
    plotly_color = plotly_color.strip()  # remove any whitespace
    if plotly_color.startswith('#'):
        return plotly_color  # matplotlib understands "#FF0013"
    elif plotly_color.startswith('rgb(') and plotly_color.endswith(')'):
        tupstr = plotly_color[len('rgb('):-1]
        tup = [float(x) / 256.0 for x in tupstr.split(',')]
        return tuple(tup)
    elif plotly_color.startswith('rgba(') and plotly_color.endswith(')'):
        tupstr = plotly_color[len('rgba('):-1]
        rgba = tupstr.split(',')
        tup = [float(x) / 256.0 for x in rgba[0:3]] + [float(rgba[3])]
        return tuple(tup)
    else:
        return plotly_color