Everything so far drew onto one Axes. Seaborn has a second family of functions, the figure-level ones (displot, catplot, relplot, pairplot), that create the whole figure themselves and return a grid object. Their reason to exist is faceting: the same plot repeated for each value of a column (col="region"), all with the same scales, so a pattern that holds in every panel is visibly real. pairplot is faceting taken to the limit: every numeric column against every other.
These functions differ in practice from the axes-level ones in two ways that matter. They return a grid (FacetGrid, PairGrid) whose .axes array you index, and they own the figure, so you cannot pass them an ax=. This question builds the three most useful: histograms per group, bars per group, and a scatter matrix.
Implement histograms_by_group(df, value, col, col_order, bins), bars_by_group(df, x, y, col, col_order) and pair_scatter(df, variables). The signatures and docstrings are already in the editor.
histograms_by_group(df, value, col, col_order, bins) returns a FacetGrid with one panel per value in col_order (left to right), each a histogram of value for that group's rows with bins bins. Use sns.displot.bars_by_group(df, x, y, col, col_order) returns a FacetGrid with one panel per value of col in col_order, each a bar chart of the mean of y for each category of x, without error bars. Use sns.catplot with kind="bar". The categories of x appear in the order of their first occurrence.pair_scatter(df, variables) returns a PairGrid with len(variables) rows and columns for exactly those numeric columns, in that order. Use sns.pairplot with vars=variables.plt.show().sns.displot(data=df, x=..., col=..., col_order=..., bins=...) returns a FacetGrid; its .axes array has one panel per column value.
sns.catplot(..., kind="bar", errorbar=None, col=...) is the figure-level version of barplot.
sns.pairplot(df, vars=[...]) draws every pair, with distributions on the diagonal.
No results yet
Run your code to check it against the examples, or submit to run every test.