【发布时间】:2019-08-16 16:43:41
【问题描述】:
我有一个名为 df 的数据框,看起来像这样:
Country R^2 Category
0 Austria 0.74 Allocation
1 Austria 0.74 Allocation
2 Austria 0.74 Allocation
3 Austria 0.71 Fixed Income
4 Austria 0.78 Allocation
5 Belgium 0.91 Equity - Global
6 Belgium 0.86 Allocation
7 Belgium 0.87 Allocation
8 Belgium 0.73 Allocation
9 Belgium 0.92 Equity - Global
10 Belgium 0.87 Fixed Income
11 Belgium 0.86 Equity - Global
我使用以下代码通过 seaborn 库可视化数据
sns.set()
g = sns.FacetGrid(df, col="Country", col_wrap=2)
g = g.map(sns.boxplot, "R^2", orient='v')
脚本为每个国家/地区生成一个箱线图,总结 R^2 分布。 但是,我也想在 x 轴上有类别。 因此,每个国家/地区的图表以及该国家/地区内每个类别的箱线图汇总 R^2。
提前致谢
【问题讨论】: