我有这个条形图,我想要做的是在每个条形图的顶部添加 percentage 。我是python的新手,我对如何执行此操作实际上并不了解。非常感谢您的帮助,并在此先感谢。
这是我的代码:
# plot the result of SARS-CoV-2 test
plt.rcParams['figure.figsize'] = 6, 8
height = df.freq
bars = df.resultado
y_pos = np.arange(len(bars))
width = [0.3, 0.3, 0.3]
# Create bars
plt.bar(y_pos, height, width = width, color = ['paleturquoise','lightskyblue','seagreen'])
# Rotation of the bars names
plt.xticks(y_pos, bars, rotation = 0)
# Add titles
plt.title('Results of SARS-CoV-2 test')
plt.ylabel('Amount of pacients of each result')
plt.xlabel('Results')
# Custom the subplot layout
plt.subplots_adjust(bottom = 0.4, top = 0.99)
# delete edges
ax = plt.axes()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
# Show graphic
plt.show()