Hi I'm trying to add value labels to a graph and I have this dataset:
I'm using this code to generate the graph for the diferent columns:
ax = dfu.plot(kind='bar', figsize=(14, 10), xlabel='Number of Employees in Company', ylabel='Count', rot=0)
ax.legend(title='treatment', bbox_to_anchor=(1, 1), loc='upper left')
rects = ax.patches
# Make some labels.
labels = [f"{i}" for i in dfu]
for rect, label in zip(rects, labels):
height = rect.get_height()
ax.text(
rect.get_x() + rect.get_width() / 2, height + 2, label, ha="center", va="bottom"
)
My main problem is that the code is taking the column name as text labels for the columns but I want to generate a list to obtain this labels and for the moment I have a for:
But is not saving all the values in one list some help here please: (At the end is the graph)
for o in dfu.columns:
col_one_arr = dfu[o]
print(col_one_arr)