def lines_equal(a, b):
    """Compare two matplotlib line segments by line style, marker, colour and label.
    Used to match legend items to data items on the axes."""
    return a.get_label() == b.get_label() and a.get_linestyle(
        ) == b.get_linestyle() and a.get_color() == b.get_color()
