diff --git a/seaborn/axisgrid.py b/seaborn/axisgrid.py index 7ab30cac6a..6e8b5a38ef 100644 --- a/seaborn/axisgrid.py +++ b/seaborn/axisgrid.py @@ -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: diff --git a/seaborn/tests/test_axisgrid.py b/seaborn/tests/test_axisgrid.py index 96c550c82f..447601dfbe 100644 --- a/seaborn/tests/test_axisgrid.py +++ b/seaborn/tests/test_axisgrid.py @@ -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