Is there a way to create a Seaborn line plot with all the lines gray and the mean as a red line? I'm trying to do this with relplot
but I don't know how to separate the mean from the data (and it appears the mean isn't being plotted?).
Make reproducible data frame
np.random.seed(1)
n1 = 100
n2 = 10
idx = np.arange(0,n1*2)
x, y, cat, id2 = [], [], [], []
x1 = list(np.random.uniform(-10,10,n2))
for i in idx:
x.extend(x1)
y.extend(list(np.random.normal(loc=0, scale=0.5, size=n2)))
cat.extend(['A', 'B'][i > n1])
id2.append(idx[i])
id2 = id2 * n2
id2.sort()
df1 = pd.DataFrame(list(zip(id2, x, y, cat)),
columns =['id2', 'x', 'y', 'cat']
)
Plotting attempt
g = sns.relplot(
data=df1, x='x', y='y', hue='id2',
col='cat', kind='line',
palette='Greys',
facet_kws=dict(sharey=False,
sharex=False
),
legend=False
)