Matplotlib Usuń zduplikowane wpisy legendy z pętli wykonywania

def legend_without_duplicate_labels(ax):
    handles, labels = axes.get_legend_handles_labels()
    unique = [(h, l) for i, (h, l) in enumerate(zip(handles, labels)) if l not in labels[:i]]
    axes.legend(*zip(*unique))
legend_without_duplicate_labels(axes)
    
plt.show(); plt.close()

corsair2014