Creating labels where line appears in matplotlib figure

tripkane picture tripkane · Nov 16, 2012 · Viewed 56.9k times · Source

I have a figure created in matplotlib (time-series data) over which are a series of

matplotlib.pyplot.axvline

lines. I would like to create labels on the plot that appear close to (probably on the RHS of the line and towards the top of the figure) these vertical lines.

Answer

Dan picture Dan · Nov 16, 2012

You can use something like

plt.axvline(10)
plt.text(10.1,0,'blah',rotation=90)

you might have to play around with the x and y value in text to get it to align properly. You can find the more complete documentation here.