Histogramas condicionales univariados con displot() —-#

  • 0:00 min | Última modificación: Octubre 13, 2021 | [YouTube]

[1]:
import matplotlib.pyplot as plt
import seaborn as sns
[2]:
penguins = sns.load_dataset("penguins")
[3]:
#
# Visualización por defecto
#
sns.displot(
    penguins,
    x="flipper_length_mm",
    hue="species",
    kind="hist",
)
plt.show()
../../_images/02_seaborn_notebooks_3-31_distributions_displot_hist_condicionales_3_0.png
[4]:
#
# Cambio de la representación visual
#
sns.displot(
    penguins,
    x="flipper_length_mm",
    hue="species",
    element="step",
)
plt.show()
../../_images/02_seaborn_notebooks_3-31_distributions_displot_hist_condicionales_4_0.png
[5]:
#
# Histogramas apilados
#
sns.displot(
    penguins,
    x="flipper_length_mm",
    hue="species",
    multiple="stack",
)
plt.show()
../../_images/02_seaborn_notebooks_3-31_distributions_displot_hist_condicionales_5_0.png
[6]:
#
# Histograma con barras agrupadas
#
sns.displot(
    penguins,
    x="flipper_length_mm",
    hue="sex",
    multiple="dodge",
)
plt.show()
../../_images/02_seaborn_notebooks_3-31_distributions_displot_hist_condicionales_6_0.png
[7]:
#
# Separación por categoria
#
sns.displot(
    penguins,
    x="flipper_length_mm",
    col="sex",
)
plt.show()
../../_images/02_seaborn_notebooks_3-31_distributions_displot_hist_condicionales_7_0.png