Skip to content

Commit

Permalink
Proof of principle refactored stripplot passing all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Jan 5, 2021
1 parent 51be45d commit 0dce5fa
Show file tree
Hide file tree
Showing 2 changed files with 343 additions and 7 deletions.
19 changes: 15 additions & 4 deletions seaborn/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, plotter):

# TODO Putting this here so we can continue to use a lot of the
# logic that's built into the library, but the idea of this class
# is to move towards semantic mappings that are agnositic about the
# is to move towards semantic mappings that are agnostic about the
# kind of plot they're going to be used to draw.
# Fully achieving that is going to take some thinking.
self.plotter = plotter
Expand Down Expand Up @@ -936,6 +936,7 @@ def _assign_variables_longform(self, data=None, **kwargs):

def iter_data(
self, grouping_vars=None, reverse=False, from_comp_data=False,
allow_empty=False,
):
"""Generator for getting subsets of data defined by semantic variables.
Expand All @@ -945,10 +946,13 @@ def iter_data(
----------
grouping_vars : string or list of strings
Semantic variables that define the subsets of data.
reverse : bool, optional
reverse : bool
If True, reverse the order of iteration.
from_comp_data : bool, optional
from_comp_data : bool
If True, use self.comp_data rather than self.plot_data
allow_empty : bool
If True, yield an empty dataframe when no observations exist for
combinations of grouping variables.
Yields
------
Expand Down Expand Up @@ -1005,7 +1009,14 @@ def iter_data(
try:
data_subset = grouped_data.get_group(pd_key)
except KeyError:
continue
if allow_empty:
# XXX we are adding this to allow backwards compatability
# with the empty artists that old categorical plots would
# add (before 0.12), which we may decide to break, in which
# case this option could be removed
data_subset = pd.DataFrame(columns=data.columns)
else:
continue

sub_vars = dict(zip(grouping_vars, key))

Expand Down
Loading

0 comments on commit 0dce5fa

Please sign in to comment.