跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 如何利用 seaborn 绘制 factorplot 图?
未分類
29 12 月 2020

如何利用 seaborn 绘制 factorplot 图?

如何利用 seaborn 绘制 factorplot 图?

資深大佬 : fanqieipnet 6

如何利用 seaborn 绘制 factorplot 图?今天番茄加速就来解答一下。

   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)

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

   sns.pointplot(x=”class”, y=”survived”, hue=”sex”, data=titanic,

   palette={“male”:”g”,”female”:”m”},markers=[“^”,”o”],linestyles=[“-“,”–“])

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

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

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

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

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

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

  关于 seaborn 使用,有一张 cheetsheet 图。

大佬有話說 (0)

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具