I try to draw a line coordinated by the x_tn, y_tn list as (x,y) and labeled by a series order as the seri list. My simplified code is as follows below. However, labels have overlapped with my line in a few locations such as (1) and (6). How to let my labels dodge the line generally? Thank you.
import matplotlib.pyplot as plt
plt.style.use('seaborn-whitegrid')
import numpy as np
x_tn = [0,1,1,2,3,2,2]
y_tn = [0,0,1,2,1,1,0]
seri = [0,1,2,3,4,5,6]
plt.title("Function")
plt.xlabel("x")
plt.ylabel("y")
plt.plot(x_tn, y_tn, '-ok')
for x,y,k in zip(x_tn,y_tn,seri):
label = f"({k})"
plt.annotate(label, # this is the text
(x,y), # these are the coordinates to position the label
textcoords="offset points", # how to position the text
xytext=(0,10), # distance from text to points (x,y)
ha='center') # horizontal alignment can be left, right or center
#specify axis tick step sizes
plt.xticks(np.arange(min(x_tn), max(x_tn)+1, 1))
plt.yticks(np.arange(min(y_tn), max(y_tn)+1, 1))
plt.show()

