Skip to content

Commit

Permalink
Raise early in jointplot when selected kind does not support hue (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Dec 12, 2020
1 parent 1974925 commit 9e6760d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions seaborn/axisgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,13 @@ def jointplot(
plot_kinds = ["scatter", "hist", "hex", "kde", "reg", "resid"]
_check_argument("kind", plot_kinds, kind)

# Raise early if using `hue` with a kind that does not support it
if hue is not None and kind in ["hex", "reg", "resid"]:
msg = (
f"Use of `hue` with `kind='{kind}'` is not currently supported."
)
raise ValueError(msg)

# Make a colormap based off the plot color
# (Currently used only for kind="hex")
if color is None:
Expand Down
6 changes: 6 additions & 0 deletions seaborn/tests/test_axisgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,12 @@ def test_bad_kind(self):
with pytest.raises(ValueError):
ag.jointplot(x="x", y="y", data=self.data, kind="not_a_kind")

def test_unsupported_hue_kind(self):

for kind in ["reg", "resid", "hex"]:
with pytest.raises(ValueError):
ag.jointplot(x="x", y="y", hue="a", data=self.data, kind=kind)

def test_leaky_dict(self):
# Validate input dicts are unchanged by jointplot plotting function

Expand Down

0 comments on commit 9e6760d

Please sign in to comment.