You can choose the location of each text as you wish using the example below:
texts
= []
for idx in range(0, len(x),2):
if idx in list(range(16, 24)):
pos_x, pos_y = x[idx] - 0.35, y[idx] + 0.01
else:
pos_x, pos_y = x[idx] + 0.25, y[idx] + 0.01
texts.append(
ax.annotate(
idx,
xy=(pos_x, pos_y),
fontsize=10,
zorder=100,
)
)