Seaborn: Support stacked bars in hue FacetGrid histograms

Created on 8 Dec 2014  路  2Comments  路  Source: mwaskom/seaborn

At the moment, it seems that FacetGrid does not support histtype='barstacked' when using FacetGrids based on hue. For example:

df = sns.load_dataset("iris")
g = sns.FacetGrid(df, hue="species", size=4, aspect=1.3)
g.map(plt.hist, "sepal_length", histtype='barstacked', stacked=True);
plt.legend();

yields:
screen shot 2014-12-08 at 15 53 34
When the user specifies:

histtype='barstacked'

It should rather yield something like:
screen shot 2014-12-08 at 15 57 58

I know this specific case is handled by default for hue plt.hist in PairGrid, but I would be happy to implement it in FacetGrid as well.
I think it would be nice to have for complex FacetGrids involving both hue and col/row.

Is this something you are interested in merging?

question

Most helpful comment

Sorry for the follow-up on this rather old issue, but how do you create the stacked histograms in the pairplot (scatterplot matrix) then? E.g.,

screen shot 2016-06-10 at 9 40 58 pm

All 2 comments

Given the differences between how PairGrid and FacetGrid work, this would be a very messy change.

If you really want to use a stacked hist, it would be better to define a function that wraps plt.hist in a way that is more compatible with the FacetGrid api. See this notebook for a recipe.

Sorry for the follow-up on this rather old issue, but how do you create the stacked histograms in the pairplot (scatterplot matrix) then? E.g.,

screen shot 2016-06-10 at 9 40 58 pm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vinay-jayaram picture vinay-jayaram  路  3Comments

queryous picture queryous  路  4Comments

chanshing picture chanshing  路  3Comments

sofiatti picture sofiatti  路  4Comments

alexpetralia picture alexpetralia  路  3Comments