作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试根据销售的总单位数(y 轴)对下表进行排序
这是我绘制的数据框:
JP_Sales NA_Sales EU_Sales
Genre
Action 158.66 861.80 516.48
Adventure 52.01 102.06 63.79
Fighting 87.15 220.74 100.00
Misc 106.67 402.48 213.82
Platform 130.65 445.99 200.67
Puzzle 56.68 122.01 50.53
Racing 56.61 356.93 236.32
Role-Playing 350.29 326.50 187.58
Shooter 38.18 575.16 310.45
Simulation 63.54 181.78 113.20
Sports 134.76 670.09 371.34
Strategy 49.10 67.89 44.94
使用此代码:
Genre_sales.plot.bar(stacked=True, figsize = (10,10))
plt.suptitle('Total Sales by Genre, separated by Region')
plt.xlabel('Genre')
plt.ylabel('Total Units Sold (Millions)')
最佳答案
如果您使用排序顺序索引到数据框,则应该这样做:
Genre_sales.loc[df.sum(axis=1).sort_values().index].plot.bar(stacked=True, figsize=(10,10))
关于python - 按总值对堆积柱形图进行排序 - Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66609664/
我想 reshape pandas 数据框, 我有这种格式的 csv 文件 #Result;ID;Date;Events;type 12;1240422;10/01/2017 10:10;1;Item
我有一个现有的 Highcharts ,我需要在其上突出显示单个列。 这是一个已经存在了一段时间的百分位图,我对 Highcharts 仍然很陌生,但我在这里看到了一个类似的问题,这个问题虽然涉及堆叠
我有一个多系列柱形图(在本例中为 3 个)。我想在所有系列的列上覆盖一条线。所以我用相同的列系列数据创建了另外 3 个 Line 系列。当只有一列和一行系列时,这非常有效。对于多个系列,线条呈现在类别
我是一名优秀的程序员,十分优秀!