def combine_legend_handles_labels(*axes):
    """ Given one or more axes, return a tuple of (lines, labels) where each label appears only once. """
    line_by_label = {}
    for ax in axes:
        lines, labels = ax.get_legend_handles_labels()
        assert len(lines) == len(labels)
        line_by_label.update(dict(zip(labels, lines)))
    labels, lines = zip(*line_by_label.items())
    return lines, labels