This is the code I have and so far the output is good but I think I can modify the label of lines "1-2", ..."8-1" better. Is there a way to make them more fitted to each part of the line? I found a related post but it's a code that gives labels for every new line but mine has a continuous line with different points
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv("data.txt",sep='[\t,]', engine='python')
print(data)
fig, ax = plt.subplots()
data.plot(x="Eastings", y="Northings", ax=ax, color = "violet", legend=None)
ax.plot(data.iloc[[0, -1]]['Eastings'], data.iloc[[0, -1]]['Northings'], color='violet')
data.plot.scatter(x="Eastings", y="Northings", ax=ax, color ="purple")
station_list = data["Station"].values.tolist()
x = data["Eastings"].values.tolist()
y = data["Northings"].values.tolist()
stat_lines = [] #making line labels such as "1-2", "2-3" ... "8-1"
for l in range(1,len(station_list)+1):
if l == (len(station_list)):
line = str(l) + '-' +str(l-(len(station_list)-1))
stat_lines.append(line)
else:
line = str(l) + '-' + str(l+1)
stat_lines.append(line)
for i, txt in enumerate(station_list):
plt.annotate(txt, (x[i], y[i]), size=15, xytext=(1,5), ha='center', textcoords='offset points', color = "blue")
for i, txt in enumerate(stat_lines):
plt.annotate(txt, (x[i]+5, y[i]+5), size=10, xytext=(1,5), ha='center', textcoords='offset points')