Skip to content

FacetGrid data no longer contains all columns from original input dataframe #2622

@SWu

Description

@SWu

After recently upgrading from seaborn 0.9.1 to 0.11.1, I noticed that after using relplot on a dataframe, the returned FacetGrid object only contains a transformed dataframe which makes FacetGrid.facet_data() return a lot less useful for additional plot manipulation using information from the original dataframe. A minimal repro:

>>> import seaborn as sns
>>> import pandas as pd
>>> import numpy as np
>>> data = pd.DataFrame(np.random.randint(0,3,size=(15, 7)), columns=list('ABCDEFG'))
>>> data.columns
Index(['A', 'B', 'C', 'D', 'E', 'F', 'G'], dtype='object')
>>> g = sns.relplot(x='A', y='B', row='C', col='D', hue='E', data=data)
>>> g.data.columns
Index(['x', 'y', 'hue', 'size', 'style', 'units', 'C', 'D'], dtype='object')
>>> for (i, j, k), data_ijk in g.facet_data():
...     data_ijk.F  # this no longer works

Previously, g.data would contain all of the original dataframe columns, and I was relying on that so that I could use g.facet_data() to augment plots with additional information from the original dataframe.

Is there a way to get back that functionality?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions