I have a list that has counts of some values and I want to make a bar plot to see the counts as bars. The list is like:
print(lii)
# Output
[46, 11, 9, 20, 3, 15, 8, 63, 11, 9, 24, 3, 5, 45, 51, 2, 23, 9, 17, 1, 1, 37, 29, 6, 3, 9, 25, 5, 43]
I want something like this plot with each list value as a bar and its value on top:
I tried the following code but it plotted the list as a series:
plt.figure(figsize=(30, 10))
plt.plot(lii)
plt.show()
Any help is appreciated.
CodePudding user response:
I believe you want something like this:
ax = sns.barplot(x=np.arange(len(lii)), y=lii)
ax.bar_label(ax.containers[0])
plt.axis('off')
plt.show()