Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a row equivalent to the 'col_wrap' parameter in seaborn's FacetGrid?

I am making a ridge plot using seaborn in python (following this example). In my case however, I have a lot more than 10 distributions, so I'd like to have multiple columns of histograms.

This all gets set up using this FacetGrid command:

g = sns.FacetGrid(df, row='date', aspect=15, height=.5)

Now, FacetGrid will wrap columns when you specify the col parameter, and then give col_wrap to be some value where any more plots will wrap around the the next row. What I would like to do instead is to specify the row parameter and have it wrap to a new column over say, 10 plots, but there doesn't seem to be a corresponding row_wrap parameter. Is there any way to work around this?

like image 731
Chris Gordon Avatar asked Jan 23 '26 09:01

Chris Gordon


1 Answers

Short answer: No (as of seaborn 0.12.2).

But interestingly, FacetGrid() has the col_wrap keyword. When wrapped, it actually yields the same result:

g = sns.FacetGrid(df, row='date', aspect=15, height=.5,
                  col="variable", col_wrap=2)
g.map_dataframe(sns.lineplot, x="year", y="share")  # just an example
like image 122
MERose Avatar answered Jan 25 '26 23:01

MERose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!