import matplotlib.ticker as ticker
import matplotlib.pyplot as plt
data = [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 5]
ax = plt.axes()
ax.text(0.25, 3, 'Firts label', rotation=90)
ax.text(1.25, 3, 'The Second One', rotation=90)
ax.text(2.25, 3, 'Labes', rotation=90)
ax.text(3.25, 3, 'Foo', rotation=90)
ax.text(4.25, 3, 'Bar', rotation=90)
plt.bar(range(len(data)), data, color='g')
plt.show()
I have a list of labels for each bar. If I create a function that take bars data as arguments, how to align the labels to the top of the bar dynamically?