Seaborn python无法正确显示轴和条带

问题描述

我正在尝试可视化Seaborn中的kaggle / titanic数据。但是它没有显示垂直轴标签和数字。同样,条/条的尺寸也没有预设计数(所有条具有相同的尺寸,并且宽度非常窄)

代码

sns.catplot('Sex',data=titanic)

我能得到什么:

catplot visualization of gender in titanic data,missed axis,narrow strips

我所期望的(基于我在Coursera课堂上看到的内容):

the image I expect to see

解决方法

您应该在kind方法中指定参数sns.catplot

import matplotlib.pyplot as plt
import seaborn as sns

titanic = sns.load_dataset("titanic")
sns.catplot("sex",data=titanic[titanic.deck.notnull()],kind="count",height=5,aspect=1)
plt.show()

enter image description here