如何进行seaborn的使用

发布时间:2022-01-06 16:49:18 作者:柒染
来源:亿速云 阅读:189

今天就跟大家聊聊有关如何进行seaborn的使用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。


seaborn 是基于matplotlib开发的,提供更高一级的接口,做出的可视化图更加具有表现力。

下面介绍 seaborn 库的入门使用方法,首先导入它和 pyplot 模块:

import matplotlib.pyplot as plt
import seaborn as sns

它里面内置了一些经典数据集,如tips, titanic, iris等,下面依次导入:

tips = sns.load_dataset("tips")
titanic = sns.load_dataset("titanic")
iris = sns.load_dataset("iris")

以titanic 为例,绘制factorplot 图,展示 sex(男、女),不同阶层(1,2,3)的 survived比率:

sns.factorplot(x="pclass", y="survived", hue="sex",data=titanic)

如何进行seaborn的使用

还可以定制 pointplot 图, 调整 markers,linestyles 等参数:

sns.pointplot(x="class", y="survived", hue="sex", data=titanic,
              palette={"male":"g","female":"m"},markers=["^","o"],linestyles=["-","--"])

如何进行seaborn的使用

不同阶层下,不同性别的存活比率 barplot 图:

sns.barplot(x="sex",y="survived", hue="class", data=titanic)

如何进行seaborn的使用

统计deck枚举值不同取值的出现频次countplot图:

sns.countplot(x="deck", data=titanic,  palette="Greens_d")

如何进行seaborn的使用

箱形图观察数据分布规律:

sns.boxplot(x="alive", y="age",hue="adult_male",data=titanic)

如何进行seaborn的使用


关于 seaborn 使用,有一张 cheetsheet 图,如下所示:


如何进行seaborn的使用


看完上述内容,你们对如何进行seaborn的使用有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

推荐阅读:
  1. seaborn是什么?
  2. seaborn如何绘制各种图形

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

seaborn

上一篇:java rpc框架的原理是什么

下一篇:python怎么实现bitcoin转账api

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》