def merge_color_and_opacity(color, opacity):
    if color is None:  # None can be used as a placeholder, just bail.
        return None

    rgb_tup = hex_to_rgb(color)
    if opacity is None:
        return 'rgb {}'.format(rgb_tup)

    rgba_tup = rgb_tup + (opacity,)
    return 'rgba {}'.format(rgba_tup)
Merge hex color with an alpha (opacity) to get an rgba tuple.
dataset/ETHPy150Open plotly/plotly.py/plotly/matplotlylib/mpltools.py/merge_color_and_opacity