在Python中以逆累积直方图可视化分组划分

问题描述

我有一个数据集,其中包含每个雇员的任期以及他/她是否仍在公司工作。我创建了一个反向累积直方图,以显示达到一定任期的员工百分比,并添加了此代码。由于仍然活跃的员工的任期价值将发生变化,因此我想将活跃的百分比与非活跃的百分比可视化。我希望将其堆叠起来,因此第一个条形图总计为100%,例如,目前有10%处于活动状态,因此条形图上方的10%应该具有不同的颜色。我无法完成此任务,因此希望有人可以提供帮助。

bins=np.linspace(0,1100,75)
ax=plt.hist(employee['Tenure'],cumulative=-1,density=True,bins=bins)
plt.xlabel('Tenure')
plt.xticks([])
plt.gca().yaxis.set_major_formatter(PercentFormatter(1))
plt.show()

Inverse cumulative density histogram representing percentage of employees that reached a certain tenure

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...