I'm creating some bar charts for all the columns in my df, but I would like to add some dots up the bar the original image I generate with my code (at the end of the post) are this ones:
And this is what I want:
Is this possible to do it with Python? suggestions or help with the code please
for i in df.columns:
#print(i)
ii= df[i].value_counts()
#dfclean[i].value_counts().plot(kind="bar", figsize=(15,7), color="#61d199", title=i)
fig, ax = plt.subplots(figsize=(15,7))
myList = ii.items()
myList = sorted(myList) # or myList for not sorted by results
x, y = zip(*myList)
for index in range(len(x)):
ax.text(x[index], y[index], y[index], size=13)
#plt.bar(x, y, color=('black', 'red', 'green', 'blue', 'cyan'))
#plt.bar(x, y, color=('#22314A'))
plt.bar(x, y, color=('#22314A', '#E35855', '#1293C4', '#FFFFFF', '#CFAB2B', '#008080', '#AE0E36'))
#plt.bar(x, y, color=('#22314A', '#E35855', '#1293C4', '#FFFFFF', '#CFAB2B'), width=0.1)# Modify width
plt.xlabel("Answers", fontsize=20)
plt.ylabel('No. answers', fontsize=20)
plt.title(i, fontsize=20)
plt.xticks(rotation=45, fontsize=16)#change rotation
plt.yticks(fontsize=16)#change rotation
i = i.replace(" ", "_")
i = i.replace("[", "_")
i = i.replace("]", "_")
i = i.replace("?", "_")
i = i.replace("/", "_")
i = i.replace(".", "_")
i = i.replace(":", "_")
#print(i)
plt.style.use('seaborn')
plt.savefig(f'{i}.png', bbox_inches='tight')
CodePudding user response: