I have x, y data for paths in the following format (sample only for illustration):
seq p1 p2
0 20 2 3
1 20 2 4
2 20 4 4
3 22 5 5
4 22 5 6
5 23 6 2
6 23 6 3
7 23 6 4
Each path has number of points and they are identified by a seq, points belonging to same seq is considered to be one path and so on..
I have plotted these paths(using my real data which is in same format as above)using the following code and also have attached the result:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(12, 8))
for (key, grp) in df.groupby("seq"):
grp.plot(linestyle = "solid", x="p1", y="p2", ax = ax, label = key)
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.title("Paths")
plt.show()
I have plotted some 40 paths, now the problem is how should I identify that which path is for uid 184, or which one is uid-194 ? They both are labelled with same color in the legend. Is there a way that I am able to identify each path distinctively, maybe labelling somewhere on the path(but that might make the graph cluttered).
My second question is I want to mark the starting and ending points of each path/ trajectory. Like start-point can be green and the end-point can be red. For example in the above sample df, for uid-20 the starting points are (2,3) in row 0 and end-points are (4,4) in row 2. Please suggest a way to mark these starting and ending points for each path in the df.