【发布时间】:2021-05-17 07:11:39
【问题描述】:
我有以下数据框:
type_of_thing group1 group 2
0 type1 0.030659 0.052632
1 type2 0.099169 0.026316
2 type3 0.184580 0.236842
3 type4 0.469446 0.605263
我想要做的是比较第一组和第二组的每种类型。我想要的图表是这样的: (在 excel 中快速制作,但我正在生成我在脚本中使用的数据框)
我的代码是这样的:
import seaborn as sns
...
rest of code
...
sns.catplot(x='type_of_thing', y=group1,kind="bar", data=df)
或者我有这个代码:
df.plot(kind='bar')
plt.show()
但是这样显示,当我希望 type_of_thing 列用作 x 轴的标签时,完全忽略 type_of_thing 列:
有谁知道我如何修复这些代码中的一个或两个以获得我想要的结果?
【问题讨论】:
标签: python python-3.x pandas matplotlib seaborn