【发布时间】:2021-10-08 20:47:32
【问题描述】:
我有以下数据框,代表每个地区每个部门/区域的员工总数。
Finance HR IT Marketing Medical Operations Sales
Business Unit
Cardiology 0 2 1 0 3 0 0
Genetics 1 4 3 1 3 1 1
Imaging 34 74 70 38 68 18 33
Labs 63 130 131 66 130 32 68
Pathology 2 5 10 4 8 3 6
使用此数据框,我使用此代码生成了波纹图:
#Plot the graph
fig, ax = plt.subplots(1, 5, figsize=(30, 15), sharey = True)
iax = iter(ax.flatten())
for n, g in df.groupby('Business Unit'):
g.loc[n, :].plot.bar(ax=next(iax), title=f'{n}', stacked=True, legend = True, fontsize = 30)
如您所见,通知业务部门的子图的文本大小以及图例大小(在顶角)太小了。我怎样才能增加他们两个的文本?
另外,有没有一种方法可以在这段代码中添加一种方法来显示每列中总数的百分比?
非常感谢您的帮助!
【问题讨论】:
标签: python pandas matplotlib seaborn bar-chart