Skip to content
Advertisement

Different binwidth for each plot in FacetGrid Seaborn

I would like to give each histplot in FacetGrid from seaborn a different binwidth. To give each plot a binwidth of 3 is possible like this:

JavaScript

Output:

enter image description here

But let’s say you want to give each plot a different binwidth, for example 1,2,3 and 4 in a list, the following error appears:

JavaScript

Error:

JavaScript

So I was wondering if anyone knows how to give each plot in the FacetGrid a different binwidth using seaborn?

Advertisement

Answer

You could loop simultaneously through g.axes_dict and the widths, and call the function separately for each subplot. You’ll need to manually create the correct subset of the dataframe.

JavaScript

sns.FacetGrid with individual parameters

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement