1

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'
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
jmich738
  • 1,565
  • 3
  • 24
  • 41

1 Answers1

1

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

Redox
  • 9,321
  • 5
  • 9
  • 26
  • I didn't even think to use `alpha` directly in `displot`. I didn't see it in the documentation so assumed it was not accessible directly. – jmich738 Aug 30 '22 at 10:22