What's a cleaner, less repeating way to pass in the coordinates here?:
plt.plot((point_A[0], point_B[0], point_C[0], point_D[0], point_E[0], point_F[0]), (point_A[1], point_B[1], point_C[1], point_D[1], point_E[1], point_F[1]))
They have values like point_A = (2,3)
I haven't written python in a while and I'd like to be idiomatic and writing clear/obvious code, without repeating.
CodePudding user response:
zip
is your friend here.
list_of_tuples = [point_A, point_B, point_C, point_D, point_E, point_F]
list_of_coords = list(zip(*list_of_tuples))
CodePudding user response:
This is just zip
:
plt.plot(*zip(point_A, point_B, point_C))
If your points are already in a list, you can use
# points = [point_A, point_B, ...]
plt.plot(*zip(*points))