With matplotlib, I am trying to annotate vertical lines that I have drawn on a plot of sequential data. With the line
plt.annotate('%.2f' % 2.34, xy=(0,0), xytext=(0,-20), xycoords='axes fraction', textcoords='offset points',color='r')
I am able to get text to show up below my plot. However, I have vertical lines plotted -- say, at intervals of 240 -- and I would like to specifically annotate each of these lines below the x-axis.
I tried switching the xycoords format to 'data' and then using xy=(240,0), but when I switch the xycoords format to 'data' the annotation text ceases to appear on my plot.
I also tried calculating the fraction where I wanted to place my annotation (e.g. 240/length of plot), but this still did not place it correctly.
Why does the annotation command stop adding text to my plot when I change the coordinate system to 'data' instead of 'axis fraction'? Thanks!