def single_label_legend(ax):
    """
    Removes duplicated labels in the legend, keeps first
    :param ax:
    :return:
    """
    handles, labels = ax.get_legend_handles_labels()
    handle_list, label_list = [], []
    for handle, label in zip(handles, labels):
        if label not in label_list:
            handle_list.append(handle)
            label_list.append(label)
    ax.legend(handle_list, label_list)
    return ax