I wan to plot a seaborn catplot with multiple columns and using the hue to differentiate some observations.
Lets say I have
import pandas as pd
import seaborn as sns
import random as r
import numpy as np
name_list=['pepe','Fabrice','jim','Michael']
country_list=['spain','France','uk','Uruguay']
favourite_color=['green','blue','red','white']
df=pd.DataFrame({'name':[r.choice(name_list) for n in range(100)],
'country':[r.choice(country_list) for n in range(100)],
'fav_color':[r.choice(favourite_color) for n in range(100)],
'score':np.random.rand(100),})
If I run
sns.catplot(y='score',hue='fav_color',col='country',data=df)
I get a TypeError: 'NoneType' object is not iterable. If I specify legend=False, I do not get any error but all points seem of the same color. I tried also to specify the palette with the same result. Is this a bug or am I doing something wrong?
sns.catplot(x="name", y='score',hue='fav_color',col='country',data=df)
– ImportanceOfBeingErnest