How to expose alpha parameter in Seaborn displot

Question:

Is there anyway to expose alpha parameter in seaborn displot function?
Here is some sample code:

import pandas as pd
import numpy as np
import seaborn as sns

A = np.random.standard_normal(20)
B = np.random.standard_normal(20)
C = ['cat1','cat2',]*10
z = pd.DataFrame({'col1':A,'col2':B,'col3':C})
sns.displot(data = z, x = 'col1',hue = 'col3')

enter image description here

I tried using hist_kws but it doesn’t seem to have it.
I want the histograms to overlap but I want them to be transparent.

sns.displot(data = z, x = 'col1',hue = 'col3',hist_kws= {'alpha': 0.1})
'Rectangle' object has no property 'hist_kws'
Asked By: jmich738

||

Answers:

To keep the histograms overlapping, but transparent, you should use alpha = 0. I think the hist_kws is valid for the older distplot. Is this what you are looking for? Just be aware that alpha=0, will not allow you to differentiate between the two plots. Maybe alpha=0.1 would help….

A = np.random.standard_normal(20)
B = np.random.standard_normal(20)
C = ['cat1','cat2',]*10
z = pd.DataFrame({'col1':A,'col2':B,'col3':C})
sns.displot(data = z, x = 'col1',hue = 'col3', alpha=0)

enter image description here

Answered By: Redox
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.