If "C" was assigned as value for the "hue" parameter, it was expected Seaborn not displayed column "C". Am I wrong?
sns.pairplot(df, hue='C')
DataFrame:
By default, seaborn will show all numeric columns!
So if your 'hue' column ('C' in your case) column as string(object) type, it will not be visible on the graph
For instance:
import numpy as np
import pandas as pd
import seaborn as sns
data = {
'A': [*np.random.random(5)],
'B': [*np.random.random(5)],
'C': ['X', 'Y', 'X', 'X', 'Y']
}
df = pd.DataFrame(data)
sns.set(style="ticks", color_codes=True)
sns.pairplot(df, hue='C')
However, if you have 'C' column as the numerical values, you have to use 'vars' to specify what columns you are going to use:
vars : list of variable names, optional
Variables within data to use, otherwise use every column with a numeric datatype.
data = {
'A': [*np.random.random(5)],
'B': [*np.random.random(5)],
'C': [*np.random.randint(1, 3, 5)]
}
df = pd.DataFrame(data)
sns.set(style="ticks", color_codes=True)
sns.pairplot(df, hue='C', vars=['A', 'B'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With