【问题标题】:Seaborn facegrid visualizationSeaborn facetgrid 可视化
【发布时间】: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。

提前致谢

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    好吧,如果您使用以下内容:

    g = sns.catplot(x="Category", y="R^2", col="Country", data=df, kind="box", aspect=.7)
    

    你会得到:

    【讨论】:

      猜你喜欢
      • 2019-01-23
      • 2019-01-02
      • 2020-11-25
      • 2021-12-22
      • 1970-01-01
      • 2017-02-02
      • 2020-08-15
      • 2016-08-03
      • 1970-01-01
      相关资源
      最近更新 更多