是在Jupyter Notebooks上进行练习,要想了解如何创建Jupyter Notebooks, 请点击这里
要想了解练习中的知识,请翻看这里来了解~~
练习使用的数据:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_style('whitegrid')
titanic = sns.load_dataset('titanic')
titanic.head()
结果如下:
使用jointplot():
sns.jointplot(x='fare',y='age',data=titanic)
结果如下:
使用distplot():
sns.distplot(titanic['fare'], kde=False,color='red',bins=30)
结果如下:
使用boxplot():
sns.boxplot(x='class',y='age',data=titanic,palette='rainbow')
结果如下:
使用swarmplot():
sns.swarmplot(x='class',y='age',data=titanic)
结果如下:
使用countplot():
sns.countplot(x='sex',data=titanic)
结果如下:
使用heatmap():
sns.heatmap(data=titanic.corr(), cmap='coolwarm')
plt.title('titanic.corr()')
结果如下:
使用FacetGrid():
g = sns.FacetGrid(data=titanic,col='sex')
g.map(sns.distplot, 'age')
结果如下:
g = sns.FacetGrid(data=titanic,col='sex')
g.map(plt.hist, 'age')
结果如下:
如果觉得不错,就点赞或者关注或者留言~~
谢谢~ ~