由于我是新手,请告诉我应该如何为右边的每个条形添加标签。如果你能解释一下代码,那就太好了...谢谢。
这是我使用的 Dataframe :
BG_donated Qty Hospital Location Contact
0 A- 25 Badr Al Sama Hospital Sohar 43445995
1 A+ 64 Aster Al Raffah Saham 58939595
2 B+ 41 Ibri Hospital Ibri 74823847
3 B- 35 Apollo Hospital Hamriyah 63947392
4 O- 51 Sultan Qaboos University Hospital Seeb 95821774
5 O+ 30 Al Hayat International Hospital Al Ghubra 44721402
6 AB- 46 KIMS Oman Hospital Darsait 37190481
7 AB+ 41 NMC Healthcare Specialty Hospital Ruwi 92810482
下面是水平条形图的代码:
y = df3['Qty'].sort_values()
w = df3['Hospital']
c = ['coral', 'salmon', 'indianred', 'brown', 'crimson', 'aquamarine',
'lightseagreen', 'slategray']
mplt.title('Analysis Report I',size = 30)
mplt.xlabel('Amount of Blood Donated',size = 15)
mplt.ylabel('Hospitals',size = 15)
mplt.barh(w,y,color = c)
mplt.show()
下面是输出:
下面是我希望它看起来的样子:
2条答案
按热度按时间oxiaedzo1#
你是说像这样?
如果是,添加“对于i,enumerate(y)中的值:
i1icjdpr2#