I have a bar chart that displays 2 bars one for 2015 and one for 2016.
- x axis shows drug name
- y axis shows amount prescribed
I would like to display annotation on the bars just to make it more clear the number prescribed. I have tried the following but nothing happens?
Does anyone know where I am going wrong?
Here is my code
for p in ax.patches:
ax.annotate(str(p.get_height()), (p.get_x() * 1.005, p.get_height() * 1.005))
fig = plt.figure() # Create matplotlib figure
ax = fig.add_subplot(111) # Create matplotlib axes
width = 0.4
df.Occurance_x.plot(kind='bar', color='purple', ax=ax, width=width, position=1)
df.Occurance_y.plot(kind='bar', color='blue', ax=ax, width=width, position=0)
ax.set_ylabel('Amount Prescribed in 1 year')
x_labels = df.VTM_NM
ax.set_xticklabels(x_labels, rotation=30)
plt.legend(['2016', '2017'], loc='upper right')
ax.set_title('BNF Chapter 1 Top 5 drugs prescribed')
plt.show()