I want to put my text vertically inside the bar graph. I tried, but couldn't get hold of it.
import pandas as pd
import matplotlib.pyplot as plt
dataF = pd.DataFrame({
'date':['12 Jul, 15','30 Aug, 17','23 Dec,19','12 Mar,21'],
'revenue':[34,25,30,38],
'status':['PAID','NOT PAID','PAID','NOT PAID']
})
print(dataF)
date revenue status
0 12 Jul, 15 34 PAID
1 30 Aug, 17 25 NOT PAID
2 23 Dec,19 30 PAID
3 12 Mar,21 38 NOT PAID
plt.close('all')
plt.rcParams['figure.figsize']=(10,6)
fig,ax = plt.subplots()
rects = ax.bar(dataF['date'], dataF['revenue'],
width=0.2, color = 'orange')
def autolabel(rects):
for rect in rects:
h = rect.get_height()
ax.text(rect.get_x()+rect.get_width()/2., 1.02*h,
str(''), ha='center', va='bottom')
autolabel(rects)
plt
Now, I want the status to appear inside the bars vertically, just as I did manually below.


