Search code examples
seabornfacet-grid

seaborn FacetGrid empty


A simple dataset, with one column named "measurement" with about 20 distinct values, and another one named "value".

g = sns.FacetGrid(data, col='measurement',col_wrap=4)
g.map(sns.displot,'value')

I get an error about the number of plots matplotlib.pyplot creates

RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam figure.max_open_warning). fig, axes = plt.subplots(nrow, ncol, **kwargs)

The 2 lines of code return me a long column with all the individual graphs and , at the end, an empty FacetGrid (snippet below). I have no idea why this is happening, anybody have a thought?

output

Thanks


Solution

  • When I tried,

    g = sns.FacetGrid(data, col='measurement',col_wrap=4)
    g.map(sns.displot,'value')
    

    I also got same results, but changing to distplot or histplot gave me the desired results. If that's what you've wanted.enter image description here