如何使用 pyplot 绘制此数据框:
Team Boys Girls
0 Sharks 5 5
1 Lions 3 7
data = {'Team': ['Sharks', 'Lions'], 'Boys': [5, 5], 'Girls': [5, 6] }
df = pd.DataFrame(data)
so that I can end up with something like this where there are two bars per team that denote the boys/girls.
对于 pyplot 来说,这似乎是一个混乱的过程,所以如果有更简单的方法,我会洗耳恭听。
您可以使用pandas.DataFrame.plot.bar https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.bar.html with rot=0
旋转 xticks
df.set_index('Team').plot.bar(rot = 0)
plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)