I have a data that I want to present as horizontal bar plots in rows and columns. I'm trying to do this with Python seaborn, which facet facility suits this purpose well.
The set of y-axis variables is different on the row dimension, and I don't want to present the empty items in facets. The problem is that the facets get the same heights while bar widths adjust. I wonder whether I could do this the opposite way so that all the bar widths would be equal in all facets, but the facet heights would adjust.
Here is an example:
import plotly.express as px
import seaborn as sns
df = px.data.tips()
g = sns.catplot(x="total_bill", y="day", col="sex", row="time", hue="smoker", data=df,
kind="bar", sharey=False, margin_titles=True)
And this is what the figure looks like (with seaborn version 0.11.2):
how to change the gridspec
To get the output you want you can set the FacetGrid's gridspec according to the number of categories:
output:
previous answer: reproducibility
If I reproduce your code with seaborn 0.11.0 I get the following output. Due to the
Categorical
values ofday
, the common days are broadcasted to all plots and the columns have the same width.update: plotly express dataset