Fix FacetGrid.data on object returned from relplot and displot #2623
+57
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2622
Context:
relplot
anddisplot
no longer use the original approach of "set up aFacetGrid
, map an axes-level function" such that theFacetGrid
owns the data. This is because they can handle wide data and data passed directly as vectors, using the relevant module-level plotting class to parse the inputs. But as a consequence, the.data
attribute on theFacetGrid
that they return does not have all the columns that were passed into the function.This PR attempts to improve that situation by merging the input dataframe with the processed dataframe used internally (which handles, e.g. the transform from wide data or vectors that were passed directly to plot kwargs, often without names).
Because input data specification is so flexible, this is a little tricky, and there may be some corner cases. For instance, if you pass a series object to one of the plot variables and it shares a name with one of the columns in the input dataframe, its data won't be represented in the output data. It may be possible to handle weird cases like that, but for now I am going to aim for simplicity / consistency with what was originally possible.
Test case with
displot
v0.11.1:
This branch:
Test case with
relplot
v0.11.1:
This branch:
TODO