Point usando catplot() —#

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

[1]:
import matplotlib.pyplot as plt
import seaborn as sns
[2]:
titanic = sns.load_dataset("titanic")

display(
    titanic.head(),
    titanic.tail(),
    titanic.size,
)
survived pclass sex age sibsp parch fare embarked class who adult_male deck embark_town alive alone
0 0 3 male 22.0 1 0 7.2500 S Third man True NaN Southampton no False
1 1 1 female 38.0 1 0 71.2833 C First woman False C Cherbourg yes False
2 1 3 female 26.0 0 0 7.9250 S Third woman False NaN Southampton yes True
3 1 1 female 35.0 1 0 53.1000 S First woman False C Southampton yes False
4 0 3 male 35.0 0 0 8.0500 S Third man True NaN Southampton no True
survived pclass sex age sibsp parch fare embarked class who adult_male deck embark_town alive alone
886 0 2 male 27.0 0 0 13.00 S Second man True NaN Southampton no True
887 1 1 female 19.0 0 0 30.00 S First woman False B Southampton yes True
888 0 3 female NaN 1 2 23.45 S Third woman False NaN Southampton no False
889 1 1 male 26.0 0 0 30.00 C First man True C Cherbourg yes True
890 0 3 male 32.0 0 0 7.75 Q Third man True NaN Queenstown no True
13365
[3]:
sns.catplot(x="sex", y="survived", hue="class", kind="point", data=titanic,)
plt.show()
../../_images/02_seaborn_notebooks_4-44_categorical_pointplots_3_0.png
[4]:
sns.catplot(x="class", y="survived", hue="sex",
            palette={"male": "g", "female": "m"},
            markers=["^", "o"], linestyles=["-", "--"],
            kind="point", data=titanic,)
plt.show()
../../_images/02_seaborn_notebooks_4-44_categorical_pointplots_4_0.png