Seaborn facegrid visualization

I have a dataframe called df, that looks like that:

    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

I use the following code to visualize the data via seaborn library

sns.set()

g = sns.FacetGrid(df, col="Country", col_wrap=2)
g = g.map(sns.boxplot, "R^2", orient='v')

The script produces a box plot for each country summarizing the R^2 distribution. However I would like to have on the x axis the categories also. So a chart for each country with boxplots for each category within the country summarizing R^2.

Thanks in advance

Upvotes: 0

Views: 81

Answers (1)

zipa
zipa

Reputation: 27869

Well, if you used the following:

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

You'd get:

enter image description here

Upvotes: 1

Related Questions