Get the draw options for a given (patch) object.

def get_draw_options(data, obj, ec, fc, style, width):
    """Get the draw options for a given (patch) object.
    """
    draw_options = []

    if ec is not None:
        data, col, ec_rgba = color.mpl_color2xcolor(data, ec)
        if ec_rgba[3] != 0.0:
            # Don't draw if it's invisible anyways.
            draw_options.append("draw={}".format(col))

    if fc is not None:
        data, col, fc_rgba = color.mpl_color2xcolor(data, fc)
        if fc_rgba[3] != 0.0:
            # Don't draw if it's invisible anyways.
            draw_options.append("fill={}".format(col))

    # handle transparency
    ff = data["float format"]
    if (
        ec is not None
        and fc is not None
        and ec_rgba[3] != 1.0
        and ec_rgba[3] == fc_rgba[3]
    ):
        draw_options.append(("opacity=" + ff).format(ec[3]))
    else:
        if ec is not None and ec_rgba[3] != 1.0:
            draw_options.append(("draw opacity=" + ff).format(ec_rgba[3]))
        if fc is not None and fc_rgba[3] != 1.0:
            draw_options.append(("fill opacity=" + ff).format(fc_rgba[3]))

    if width is not None:
        w = mpl_linewidth2pgfp_linewidth(data, width)
        if w:
            draw_options.append(w)

    if style is not None:
        ls = mpl_linestyle2pgfplots_linestyle(style)
        if ls is not None and ls != "solid":
            draw_options.append(ls)

    return data, draw_options