python - Numpy zip array for LineCollection -
is there simple way zip numpy columns used input linecollection?
current format
note array has many more elements used.
arr=([(x1, y1, z1, a1, b1, c1), (x2, y2, z2, a2, b2, c2), (x3, y3, z3, a3, b3, c3)])
desired format
i lines in following format might able use linecollection:
lines = [[(x1, x2), (y1, y2)], [(x2, x3), (y2, y3)] ...] linecollection(lines)
i not know direct numpy functions or such trick.
but if want first 2 elements each sublist , can try -
arr = [(1,2,3,),(2,3,4),(3,4,5),(4,5,6),(5,6,7),(6,7,8)] lines = [] in range(len(arr)-1): lines.append([(arr[i][0],arr[i+1][0]),(arr[i][1],arr[i+1][1])]) lines >>> [[(1, 2), (2, 3)], [(2, 3), (3, 4)], [(3, 4), (4, 5)], [(4, 5), (5, 6)], [(5, 6), (6, 7)]]
Comments
Post a Comment