How to break the connection between the first and last point in line

Hi @peter34 ,

This line that cross from last point to first point maybe caused by your last point that has smallest x value or your last point is pushed to first point.

Try to sort the array by x value before put it into plot. Maybe you could put it inside extract_xy function.

def extract_xy(input_array):
    input_array = sorted(input_array, key=lambda item: item[1]) # sort array by x value 
    x = [item[1] for item in input_array]
    y = [item[0] for item in input_array]
    return x, y

you can also refer to this similar post.

Hope this help.

1 Like