I'm having some difficulty finding an easy way to label a bar graph with values above the bar, as I have multiple groups of bars. The code is written in Python 3.8 and attached below.
import numpy as np
df_Data = df_data.sort_values(by = 'Very interested', ascending = False)
df_per = ((df_Data.iloc[0:len(df_Data),1:4]/2233)*100).round(2)
names = ["Data Analysis / Statistics", "Machine Learning", "Data Visualization", "Big Data (Spark / Hadoop)", "Deep Learning", "Data Journalism "]
bar_chart = df_per.plot(kind = 'bar', figsize = (20,8), width = 0.8, color = ['#5cb85c','#5bc0de','#d9534f'])
plot.legend(frameon = False)
position = []
list = []
empty = []
for x in range(0,len(df_per)):
position.append(x)
yval = np.array(position)
plot.xticks(yval, names)
bar_label = np.arange(0,100,10)
for x in range(0,len(df_per)):
values_array = df_per.iloc[x].to_numpy()
list.append(values_array)
for position in range(0,len(df_per)):
positional_values = np.array([position-0.3,position-0.1, position+0.2])
empty.append(positional_values)
for index in range(0,3):
for group in range(0,len(empty)):
bar_chart.text(empty[group][index], list[group][index], list[group][index])
for spine in bar_chart.spines:
bar_chart.spines[spine].set_visible(False)
The produced graph: