失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 【可视化】seaborn常用的10种数据分析图表

【可视化】seaborn常用的10种数据分析图表

时间:2020-04-10 01:16:13

相关推荐

【可视化】seaborn常用的10种数据分析图表

文章来源于Python大数据分析,作者朱卫军

内置示例数据集

seaborn内置了十几个示例数据集,通过load_dataset函数可以调用。

其中包括常见的泰坦尼克、鸢尾花等经典数据集。

#查看数据集种类importseabornassnssns.get_dataset_names()

importseabornassns#导出鸢尾花数据集data=sns.load_dataset('iris')data.head()

1、散点图

函数sns.scatterplot

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinline#小费数据集tips=sns.load_dataset('tips')ax=sns.scatterplot(x='total_bill',y='tip',data=tips)plt.show()

2、条形图

函数sns.barplot

显示数据平均值和置信区间

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinline#小费数据集tips=sns.load_dataset("tips")ax=sns.barplot(x="day",y="total_bill",data=tips)plt.show()

3、线型图

函数sns.lineplot

绘制折线图和置信区间

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlinefmri=sns.load_dataset("fmri")ax=sns.lineplot(x="timepoint",y="signal",data=fmri)plt.show()

4、箱线图

函数seaborn.boxplot

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlinetips=sns.load_dataset("tips")ax=sns.boxplot(x="day",y="total_bill",data=tips)plt.show()

5、直方图

函数seaborn.distplot

importseabornassnsimportnumpyasnpsns.set()importmatplotlib.pyplotasplt%matplotlibinlinenp.random.seed(0)x=np.random.randn(1000)ax=sns.distplot(x)plt.show()

6、热力图

函数seaborn.heatmap

importnumpyasnpnp.random.seed(0)importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlineuniform_data=np.random.rand(10,12)ax=sns.heatmap(uniform_data)plt.show()

7、散点图矩阵

函数sns.pairplot

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlineiris=sns.load_dataset("iris")ax=sns.pairplot(iris)plt.show()

8、分类散点图

函数seaborn.catplot

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlineexercise=sns.load_dataset("exercise")ax=sns.catplot(x="time",y="pulse",hue="kind",data=exercise)\plt.show()

9、计数条形图

函数seaborn.countplot

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlinetitanic=sns.load_dataset("titanic")ax=sns.countplot(x="class",data=titanic)plt.show()

10、回归图

函数seaborn.lmplot

绘制散点及回归图

importseabornassnssns.set()importmatplotlib.pyplotasplt%matplotlibinlinetips=sns.load_dataset("tips")ax=sns.lmplot(x="total_bill",y="tip",data=tips)plt.show()

-END-

往期精彩回顾适合初学者入门人工智能的路线及资料下载机器学习在线手册深度学习在线手册AI基础下载(pdf更新到25集)本站qq群1003271085,加入微信群请回复“加群”获取一折本站知识星球优惠券,复制链接直接打开:/yFQV7am喜欢文章,点个在看

如果觉得《【可视化】seaborn常用的10种数据分析图表》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。