python - 如何在熊猫 barh 图中仅堆叠选定的列
问题描述
我正在尝试绘制一个条形图,其中我想要两个条形图,一个堆叠,另一个未堆叠在堆叠的一侧。
我有第一个图,它是一个堆叠图:
另一个情节,具有相同的行和列:
我想将它并排绘制到最后一个图的列,而不是堆叠它:
这是复制我的问题的代码片段:
d = pd.DataFrame({'DC': {'col0': 257334.0,
'col1': 0.0,
'col2': 0.0,
'col3': 186146.0,
'col4': 0.0,
'col5': 366431.0,
'col6': 461.0,
'col7': 0.0,
'col8': 0.0},
'DC - IDC': {'col0': 32665.0,
'col1': 0.0,
'col2': 156598.0,
'col3': 0.0,
'col4': 176170.0,
'col5': 0.0,
'col6': 0.0,
'col7': 0.0,
'col8': 0.0},
'No Address': {'col0': 292442.0,
'col1': 227.0,
'col2': 298513.0,
'col3': 117167.0,
'col4': 249.0,
'col5': 747753.0,
'col6': 271976.0,
'col7': 9640.0,
'col8': 211410.0}})
d[['DC', 'DC - IDC']].plot.barh(stacked=True)
d[['No Address']].plot.barh( stacked=False, color='red')
解决方案
推荐阅读
- python - 使用具有各种参数的 GridSearch 进行超参数调整
- google-cloud-platform - 谷歌数据融合 xml 解析 - 'parse-xml-to-json':6 处不匹配的关闭标签注释
- android - 如何为android中的每个活动创建单独的工具栏?
- python - 通过 Python 从 Excel 工作表中提取单词
- python - Python:如何将 eval() 的输出保存在变量中?
- android - 如何在 roomdb 查询中使用 where 关键字
- javascript - 删除axios方法返回空数据
- sql - 缺少关键字 oracle SQL 00905
- algorithm - 与起点相比,终点是否距离任意点近 x%
- scheme - 是否有 SICP 练习的风格指南?