I have a list of coordinates arranged in a specific order.
shortest_route = [(2, 8), (2, 8), (1, 3), (0, 2), (0, 0), (6, 1), (9, 3), (8, 4), (7, 4), (6, 4), (2, 8)]
I am trying to plot the coordinates points and connect them in that order. My idea was to iterate through the list using a for loop, then plotting the coordinate points one by one, and connecting them with a line.
for g in shortest_route:
print(g)
plt.plot(x, y, '-o')
plt.show()
Based on the image, I can tell that the points are not connected in order and that the shape of the graph is not closed off. The last two coordinate points line would allow the graph to be closed off.
Or
plt.plot(*zip(*shortest_route), '-o')
;-)@JohanC : Yeah, even shorter. I though prefer a slightly explicit version :)