Repository: mwaskom/seaborn

Issue:
Scatterplot with single-valued boolean column for Hue gives faded plot & bad legend
Using a Boolean column for hue in a scatterplot gives a plot with faded points and a legend with the same color for True and False.

![image](https://user-images.githubusercontent.com/49426320/55934221-e9455780-5bfd-11e9-9de8-f7120ba0d84d.png)

```
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

sns.set()

# Create example DataFrame of stock values
df = pd.DataFrame({
    'ticker':np.repeat( ['aapl','goog','yhoo','msft'], 25 ),
    'date':np.tile( pd.date_range('1/1/2011', periods=25, freq='D'), 4 ),
    'price':(np.random.randn(100).cumsum() + 10) })

df['split'] = False
df['split 2'] = "No"


plt.figure()
sns.scatterplot(x=df.date.dt.strftime('%Y-%w'), y='price', data=df, hue='split')
plt.figure()
sns.scatterplot(x=df.date.dt.strftime('%Y-%w'), y='price', data=df, hue='split 2')
```



Discussion:

Patch:
diff --git a/seaborn/relational.py b/seaborn/relational.py
index 77bebe30..4a8741bd 100644
--- a/seaborn/relational.py
+++ b/seaborn/relational.py
@@ -530,7 +530,8 @@ class _RelationalPlotter(object):
             try:
                 float_data = data.astype(np.float)
                 values = np.unique(float_data.dropna())
-                if np.array_equal(values, np.array([0., 1.])):
+                # TODO replace with isin when pinned np version >= 1.13
+                if np.all(np.in1d(values, np.array([0., 1.]))):
                     return "categorical"
                 return "numeric"
             except (ValueError, TypeError):


Test patch:
diff --git a/seaborn/tests/test_relational.py b/seaborn/tests/test_relational.py
index 874c1d90..502be817 100644
--- a/seaborn/tests/test_relational.py
+++ b/seaborn/tests/test_relational.py
@@ -476,6 +476,16 @@ class TestRelationalPlotter(object):
         assert p.hue_levels == [0, 1]
         assert p.hue_type is "categorical"
 
+        df=long_df[long_df["c"]==0]
+        p = rel._LinePlotter(x="x", y="y", hue="c", data=df)
+        assert p.hue_levels == [0]
+        assert p.hue_type is "categorical"
+
+        df=long_df[long_df["c"]==1]
+        p = rel._LinePlotter(x="x", y="y", hue="c", data=df)
+        assert p.hue_levels == [1]
+        assert p.hue_type is "categorical"
+
         # Test numeric data with category type
         p = rel._LinePlotter(x="x", y="y", hue="s_cat", data=long_df)
         assert p.hue_levels == categorical_order(long_df.s_cat)