data = sns.load_dataset("penguins")
sns.displot(data=data, x="bill_length_mm", rug=True, hue="sex", bins=20)
plt.show()
If you don’t specify the data for the y-axis, it will represent the number of occurrences, and if you don’t specify the kind, it defaults to a histogram. The bins argument controls the number of bars.
We also have access to kernel density estimation (KDE) to estimate a distribution. Here is an example of how to use it:
data = sns.load_dataset("penguins")
sns.displot(data=data,x="bill_length_mm", rug=True, hue="sex", kind="kde")
plt.show()

If you specify a variable for the y-axis:
data = sns.load_dataset("penguins")
sns.displot(data=data,x="bill_length_mm", y="bill_depth_mm", rug=True, hue="sex", kind="kde")
plt.show()

The rug parameter allows you to display individual observations along the axes of the plot.
The last type of distribution available is the ECDF (empirical cumulative distribution function). You cannot specify a y variable for this distribution since it is univariate.
data = sns.load_dataset("penguins")
sns.displot(data=data, x="body_mass_g", rug=True, hue="sex", kind="ecdf", row="species", col="sex", height=5)
plt.show()
The row parameter allows you to display additional plots based on another variable in the dataset. The height parameter controls the height of the plots.