python - 如何像在 ggplot 中一样在 matplotlib 中创建堆积条形直方图
问题描述
我正在尝试使用 matplotlib 中的堆积条来可视化 UCI 成人收入数据集中的年龄和收入。不幸的是,结果并不像我预期的那样。
在R中,代码是这样的
library(ggplot2)
ggplot(adult, aes(age)) + geom_histogram(aes(fill = income), color = "black",binwidth = 1)
结果是这样的
我正在使用这段代码:
plt.figure(figsize=(16, 8))
plt.hist(adult.age, bins=10, normed=None, histtype='bar', stacked=True)
plt.show()
你们能指出我错在哪里吗?
谢谢
解决方案
推荐阅读
- three.js - 三.js奇怪的工件重叠框和平面
- go - 带参数的 Dialogflow 响应
- wordpress - 如何在联系表格 7 中手动发送电子邮件
- javascript - 在对 Express node.js 应用程序进行单元测试时如何模拟 Redis?
- jointjs - 在快速框架中。使用 fromJSON 方法重新创建时,链接元素无法指向端口
- javascript - html文件显示在底部位置
- html - 减少超链接中文本和下划线之间的间距
- python - python有项目知识阅读器模块吗?
- javascript - ReactDOM 没有显示
- javascript - React TypeError:this.state.List.map 不是函数