I have the following lists that correspond to 6 (clients) points (each one having an id, and x and y coordinates)
allIds = [0, 1, 2, 3, 4, 5],
allxs = [50, 25, 43, 80, 25, 18]
allys = [50, 54, 96, 50, 90, 47]
For example, the 1st point has an id of 0, its x coordinates are 50, and its y coordinates are 50, and so on.
I am trying to solve a traveling salesman problem, so I want to plot the points of a specific route between points, connected with a line that will represent the closed route.
The final route I want to plot is represented by the following list:
final_route = [0, 4, 5, 2, 1, 3, 0]
and represents a path between clients' ids
So far i have only managed to plot the points only, with the following code:
fig, ax = plt.subplots()
fig.set_size_inches(6, 6)
ax.plot(all_x, all_y, ls="", marker="o", markersize=8)
for xi, yi, pidi in zip(all_x, all_y, all_ids):
ax.annotate(str(pidi), xy=(xi,yi))
plt.xlim([0, 100])
plt.ylim([0, 100])
plt.show()
Which produces the following plot: Plot of poits
Any ideas about how to plot the line between the points? Thanks