def plot_legend(ax, handles, bbox_to_anchor=(1.05, 1), loc=2, fg='black',
    bg='white', title=None):
    """add legend to figure"""
    leg = ax.legend(handles=handles, frameon=False, title=title,
        bbox_to_anchor=bbox_to_anchor, loc=loc, facecolor=bg)
    for text in leg.get_texts():
        text.set_color(fg)
