xi = np.insert(xi, indices, x)
yi = np.insert(yi, indices, y)
return reshuffle(xi, yi), ti

def reshuffle(x, y):
    """Reshape the line represented by "x" and "y" into an array of individual
    segments."""
points = np.vstack([x, y]).T.reshape(-1, 1, 2)
points = np.concatenate([points[:-1], points[1:]], axis=1)
return points
if __name__ == '__main__':
    main()
Matplotlib: как эффективно раскрасить большое количество сегментов линий в виде независимых градиентов