I'm trying to add labels in the bars of my group bar chart and I'm having problem doing so this is my code:`
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('lifeExpectancy_SEA.csv')
bar = df.pivot(index = 'SEA_Countries ', columns = 'Years', values = 'Average_Age')
bar.plot(kind = 'bar',figsize = (20,8))
plt.xlabel('SEA Countries')
plt.ylabel('Average Life Expectancy of the population')
plt.title('Average Life Expectancy of the SEA population from the years 1950-1969 and 2000-2019')
plt.legend(loc = 'upper right')
plt.grid(axis= 'y', color = 'green', linestyle = '--')
fig, ax = plt.subplots()
ax.bar_label() #tried adding the proper parameters but still ended up with the same error
plt.show()
The error message is this:
AttributeError: 'AxesSubplot' object has no attribute 'bar_label'
Any comments or suggestions is greatly appreciated!