二.分类图

1. 分类散点图

(1)散点图striplot(kind='strip')

方法1:

seaborn.stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, jitter=True, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)

方法2:catplot的kind默认=striplot

sns.catplot(x="sepal_length", y="species", data=iris)

  

(2)带分布的散点图swarmplot(kind='swarm'

方法1:

seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)

方法2:

 sns.catplot(x="sepal_length", y="species", kind="swarm", data=iris)   

2. 分类分布图

(1)箱线图boxplot(kind='box'

方法1:

seaborn.boxplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, width=0.8, dodge=True, fliersize=5, linewidth=None, whis=1.5, notch=False, ax=None, **kwargs)

方法2:

sns.catplot(x="sepal_length", y="species", data=iris)

  

(2)小提琴图violinplot(kind='violin'

方法1:

seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, bw='scott', cut=2, scale='area', scale_hue=True, gridsize=100, width=0.8, inner='box', split=False, dodge=True, orient=None, linewidth=None, color=None, palette=None, saturation=0.75, ax=None, **kwargs)

方法2:

sns.catplot(x="sepal_length", y="species", kind="violin", data=iris)

 

(3)boxenplot(kind='boxen')

方法1:

seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, width=0.8, dodge=True, k_depth='proportion', linewidth=None, scale='exponential', outlier_prop=None, ax=None, **kwargs)

方法2:

sns.catplot(x="species", y="sepal_length", kind="boxen", data=iris)

  

3. 分类估计图

(1)pointplot(kind='point')

方法1:

seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, markers='o', linestyles='-', dodge=False, join=True, scale=1, orient=None, color=None, palette=None, errwidth=None, capsize=None, ax=None, **kwargs)

方法2:

sns.catplot(x="sepal_length", y="species", kind="point", data=iris)

  

(2)直方图barplot(kind='bar'

方法1:

seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, orient=None, color=None, palette=None, saturation=0.75, errcolor='.26', errwidth=None, capsize=None, dodge=True, ax=None, **kwargs)

方法2:

sns.catplot(x="sepal_length", y="species", kind="bar", data=iris)

  

(3)计数的直方图countplot(kind='count'

方法1:

seaborn.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)

方法2:

sns.catplot(x="species", kind="count", data=iris)

  

三.分布图

包括单变量核密度曲线,直方图,双变量多变量的联合直方图,和密度图

1.单分布

(1)distpot

方法:

seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kws=None, kde_kws=None, rug_kws=None, fit_kws=None, color=None, vertical=False, norm_hist=False, axlabel=None, label=None, ax=None)
  • seaborn.distplot

  • 设置 kde=False 则可以只绘制直方图,或者 hist=False 只绘制核密度估计图

举例:

sns.distplot(iris["sepal_length"])

  

(2)kdeplot

方法:

seaborn.kdeplot(data, data2=None, shade=False, vertical=False, kernel='gau', bw='scott', gridsize=100, cut=3, clip=None, legend=True, cumulative=False, shade_lowest=True, cbar=False, cbar_ax=None, cbar_kws=None, ax=None, **kwargs)
  • kdeplot 可以专门用于绘制核密度估计图,其效果和 distplot(hist=False) 一致,但 kdeplot 拥有更多的自定义设置
  • seaborn.kdeplot

举例:

sns.kdeplot(iris["sepal_length"])

  

2.双分布

(1)jointplot二元变量分布图

方法:

seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, joint_kws=None, marginal_kws=None, annot_kws=None, **kwargs)
  • seaborn.jointplot

  • jointplot 并不是一个 Figure-level 接口,但其支持 kind= 参数指定绘制出不同样式的分布图。例如,绘制出核密度估计对比图 kind = 'kde'。
  • kind='hex'绘制六边形计数图
  • kind='reg'绘制回归拟合图

举例:

例如,我们探寻 sepal_length 和 sepal_width 二元特征变量之间的关系。

sns.jointplot(x="sepal_length", y="sepal_width", data=iris)

  

(2)pairpot

支持将数据集中的特征变量两两对比绘图,默认情况下,对角线上是单变量分布图,而其他是二元变量分布图

方法:

seaborn.pairplot(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind='scatter', diag_kind='auto', markers=None, height=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None, size=None)

举例:

sns.pairplot(iris, hue="species")

  

(3)rugplot

 方法:

seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)

  

四.回归图

回归图只要探讨两连续数值变量的变化趋势情况,绘制x-y的散点图和回归曲线。

1.lmplot

方法:

seaborn.lmplot(x, y, data, hue=None, col=None, row=None, palette=None, col_wrap=None, height=5, aspect=1, markers='o', sharex=True, sharey=True, hue_order=None, col_order=None, row_order=None, legend=True, legend_out=True, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, x_jitter=None, y_jitter=None, scatter_kws=None, line_kws=None, size=None)
  • seaborn.lmplot
  • lmplot 同样是用于绘制回归图,但 lmplot 支持引入第三维度进行对比,例如我们设置 hue="species"

举例:

sns.lmplot(x="sepal_length", y="sepal_width", hue="species", data=iris)

  

2.regplot

方法:用线性回归模型对数据做拟合

seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, dropna=True, x_jitter=None, y_jitter=None, label=None, color=None, marker='o', scatter_kws=None, line_kws=None, ax=None)
  • seaborn.regplot
  • regplot 绘制回归图时,只需要指定自变量和因变量即可,regplot 会自动完成线性回归拟合。

举例:

sns.regplot(x="sepal_length", y="sepal_width", data=iris)

  

3.residplot

方法:展示线性回归模型拟合后各点对应的残值

seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None, order=1, robust=False, dropna=True, label=None, color=None, scatter_kws=None, line_kws=None, ax=None)

  

 举例:可以对以年为单位的地震记录作线性回归拟合。以下两张图分别对应一阶线性回归拟合、拟合后残值分布情况图。

plt.figure(figsize=(12,6))
plt.subplot(121)
sns.regplot(x="Year", y="ID",
data=temp,order=1) # default by 1plt.ylabel(' ')
plt.title('Regression fit of earthquake records by year,order = 1') plt.subplot(122)
sns.residplot(x="Year", y="ID",
data=temp)
plt.ylabel(' ')
plt.title('Residual plot when using a simplt regression
model,order=1')
plt.show()

  

五.矩阵图

1.热力图heatmap

方法:用颜色矩阵去显示数据在两个维度下的度量值

seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False, annot=None, fmt='.2g', annot_kws=None, linewidths=0, linecolor='white', cbar=True, cbar_kws=None, cbar_ax=None, square=False, xticklabels='auto', yticklabels='auto', mask=None, ax=None, **kwargs)
  • 热力图在某些场景下非常实用,例如绘制出变量相关性系数热力图。
  • seaborn.heatmap

举例:

import numpy as np

sns.heatmap(np.random.rand(10, 10))

  

2.聚类图clustermap

方法:

seaborn.clustermap(data, pivot_kws=None, method='average', metric='euclidean', z_score=None, standard_scale=None, figsize=None, cbar_kws=None, row_cluster=True, col_cluster=True, row_linkage=None, col_linkage=None, row_colors=None, col_colors=None, mask=None, **kwargs)
  • 除此之外,clustermap 支持绘制层次聚类结构图。如下所示,我们先去掉原数据集中最后一个目标列,传入特征数据即可。当然,你需要对层次聚类有所了解,否则很难看明白图像多表述的含义。
  • seaborn.clustermap

举例:

iris.pop("species")
sns.clustermap(iris)

  

六.时间序列图

1.时间序列图tsplot

用时间维度序列去展现数据的不确定性

2.网格时序图plot_ts_d , plot_ts_m

七.多绘图网格

1.小平面网格

1.1 FaceGrid

1.2 FacetGrid.map

1.3 FacetGrid.map_dataframe

2.配对网格

2.1 PairGrid

2.2 PairGrid.map

2.3 PairGrid.map_diag

2.4 PairGrid.map_offdiag

2.5 PairGrid.map_lower

2.6 PairGrid.map_upper

3.联合网格

3.1 JointGrid

3.2 JointGrid.plot

3.3 JointGrid.plot_joint

3.4 JointGrid.plot_marginals

参考文献:

【1】Python学习笔记——数据分析之Seaborn绘图

【2】5种方法教你用Python玩转histogram直方图

【3】机器学习开放课程:二、使用Python可视化数据

【4】python可视化进阶---seaborn1.7 分类数据可视化 - 统计图 barplot() / countplot() / pointplot()

【5】seaborn官网

【6】Seaborn 数据可视化基础教程

seaborn(2)---画分类图/分布图/回归图/矩阵图的更多相关文章

  1. Python图表数据可视化Seaborn:2. 分类数据可视化-分类散点图|分布图(箱型图|小提琴图|LV图表)|统计图(柱状图|折线图)

    1. 分类数据可视化 - 分类散点图 stripplot( ) / swarmplot( ) sns.stripplot(x="day",y="total_bill&qu ...

  2. Matplotlib学习---用seaborn画矩阵图(pair plot)

    矩阵图非常有用,人们经常用它来查看多个变量之间的联系. 下面用著名的鸢尾花数据来画一个矩阵图.从sklearn导入鸢尾花数据,然后将其转换成pandas的DataFrame类型,最后用seaborn画 ...

  3. Python统计分析可视化库seaborn(相关性图,变量分布图,箱线图等等)

    Visualization of seaborn  seaborn[1]是一个建立在matplot之上,可用于制作丰富和非常具有吸引力统计图形的Python库.Seaborn库旨在将可视化作为探索和理 ...

  4. Python图表数据可视化Seaborn:1. 风格| 分布数据可视化-直方图| 密度图| 散点图

    conda  install seaborn  是安装到jupyter那个环境的 1. 整体风格设置 对图表整体颜色.比例等进行风格设置,包括颜色色板等调用系统风格进行数据可视化 set() / se ...

  5. Python图表数据可视化Seaborn:3. 线性关系数据| 时间线图表| 热图

    1. 线性关系数据可视化 lmplot( ) import numpy as np import pandas as pd import matplotlib.pyplot as plt import ...

  6. seaborn学习笔记(四):箱型图、小提琴图

    html { font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100% } body { ...

  7. 【R作图】lattice包,画多个分布柱形图,hist图纵轴转换为百分比

    一开始用lattice包,感觉在多元数据的可视化方面,确实做得非常好.各种函数,可以实现任何想要实现的展示. barchart(y ~ x) y对x的直方图 bwplot(y ~ x) 盒形图 den ...

  8. haploview画出所有SNP的LD关系图

    有时候我们想画出所有SNP的LD关系图,则需要在命令行添加“-skipcheck”命令行,如下所示: java -jar Haploview.jar -skipcheck -n -pedfile 80 ...

  9. 还能这么玩?用VsCode画类图、流程图、时序图、状态图...不要太爽!

    文章每周持续更新,各位的「三连」是对我最大的肯定.可以微信搜索公众号「 后端技术学堂 」第一时间阅读(一般比博客早更新一到两篇) 软件设计中,有好几种图需要画,比如流程图.类图.组件图等,我知道大部分 ...

随机推荐

  1. 配置tomcat服务器内存大小中的Xms、Xmx、PermSize、MaxPermSize 详解

    1.参数的含义 -vmargs -Xms256m -Xmx512m -XX:PermSize=256M -XX:MaxPermSize=512M -vmargs 说明后面是VM的参数,所以后面的其实都 ...

  2. k8s 相关的命令

    查看node信息 kubectl describe node k8s-node- 查看dashboard token kubectl describe pod kubernetes-dashboard ...

  3. Flume+Kafka+Storm+Redis 大数据在线实时分析

    1.实时处理框架 即从上面的架构中我们可以看出,其由下面的几部分构成: Flume集群 Kafka集群 Storm集群 从构建实时处理系统的角度出发,我们需要做的是,如何让数据在各个不同的集群系统之间 ...

  4. Selenium基础教程(三)自动化插件Katalon

    Katalon-一款好用的selenium自动化测试插件 Selenium 框架是目前使用较广泛的开源自动化框架,一款好的.基于界面的录制工具对于初学者来说可以快速入门:对于老手来说可以提高开发自动化 ...

  5. SQL Server ----- 备份数据库 生成(.bak)文件

    转移数据库   备份数据库 选中数据库 进入后界面如图 选择合适位置进行备份 注意:选择配置好保存位置的 成功后出现 如果出现错误. 还有一种可能是哪个文件夹中已经有了一个 把文件家中的那个删了 还原 ...

  6. jquery.i18n.properties前端国际化方案

    如果新项目要做系统国际化, 时下热门的任何一种技术选型都有成熟的方案,比如: vue + vue-i18n angular + angular-translate react + react-intl ...

  7. 关于AQS的一点总结

    关于AQS的一点总结 2017年03月13日 09:48:13 那只是一股逆流 阅读数:772    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/ ...

  8. .NET Core中如何对Url进行编码和解码

    我们在.NET Core项目中,可以用WebUtility类对Url进行编码和解码,首先我们要确保项目中引入了nuget包:System.Runtime.Extensions 当然这个nuget包默认 ...

  9. Windwos利用批处理文件自动清理归档日志,计划任务

    首先在X盘根目录建立一个文档  cmd.txt 打开cmd.txt这个文本文件,在里面第一行写入 DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-3'; ...

  10. 自定义WPF Popup控件

    解决问题 1.WPF Popup 不随着 Window 一起移动的问题 2.WPF Popup 总是显示在最前面 引用命名空间 xmlns:ctrl="clr-namespace:Micro ...