The idea seems to have originated first(?) in Visual Statistics Book by Young and Vaeiro-Mora.
The idea is pretty simple: Overlay histograms of different widhts, in a way averaging them. The density is then gauged by the degree of "darkness" of the shade. Higher the density, higher is the shade at that point.
In [1]:
%pylab inline
import seaborn as sns
In [2]:
x = np.random.normal(loc=3, scale=1, size=1000)
y = np.random.normal(loc=10, scale=1, size=1000)
z = np.concatenate([x, y])
In [3]:
sns.kdeplot(z)
Out[3]:
In [4]:
fig, ax = plt.subplots()
for n_bins in range(10, 50):
n, bins, patches = ax.hist(z, n_bins,
histtype = 'step',
fill = 'green',
density=1,
facecolor='green',
alpha=0.1,
color='green')
In [ ]: