Seaborn-04-Jointplot两变量图

#-*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

绿色:#6AB27B
土色:#a27712
浅紫色:#8172B2
蓝色:#4C72B0
红色:#C44E52

用于2个变量的画图

1、基本参数

seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=, color=None, size=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, joint_kws=None, marginal_kws=None, annot_kws=None, **kwargs)
特殊参数:

kind : { “scatter” | “reg” | “resid” | “kde” | “hex” }

基本:
  • color : 颜色。参数类型: matplotlib color
  • size : 默认 6,图的尺度大小(正方形)。参数类型:numeric
  • ratio : 中心图与侧边图的比例,越大、中心图占比越大。参数类型:numeric
  • space : 中心图与侧边图的间隔大小。参数类型:numeric
  • s : 点的大小。参数类型:numeric
  • linewidth : 线的宽度。参数类型:numeric
  • edgecolor : 点的边界颜色,默认无色,可以重叠。"w"为白色。参数类型:matplotlib color
  • {x, y}lim : x、y轴的范围。参数类型:two-tuples
  • {joint, marginal, annot}_kws : dicts Additional keyword arguments for the plot components.
    marginal_kws : 侧边图的信息。例如:dict(bins=15, rug=True)
    annot_kws : 注释的信息。例如:dict(stat="r")
返回:

JointGrid 对象

2、散点图

tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips)
g2 = sns.jointplot(x="total_bill", y="tip", data=tips, kind="scatter")
Seaborn-04-Jointplot两变量图_第1张图片
04_01.png

3、回归图

g3 = sns.jointplot("total_bill", "tip", data=tips, kind="reg")
Seaborn-04-Jointplot两变量图_第2张图片
04_02.png

4、六角图

g4 = sns.jointplot("total_bill", "tip", data=tips, kind="hex")
Seaborn-04-Jointplot两变量图_第3张图片
04_03.png

5、KDE 图

g5 = sns.jointplot("total_bill", "tip", data=tips, kind="kde", space=0, color="#6AB27B")
Seaborn-04-Jointplot两变量图_第4张图片
04_04.png

6、分类变量与连续变量的图

g6 = sns.jointplot("size", "total_bill", data=tips, color="#8172B2")
Seaborn-04-Jointplot两变量图_第5张图片
04_05.png

7、图相交:散点图+KDE 图

iris = sns.load_dataset("iris")
g7 = (sns.jointplot("sepal_length", "sepal_width", data=iris, color="k")
      .plot_joint(sns.kdeplot, zorder=0, n_levels=6))
Seaborn-04-Jointplot两变量图_第6张图片
04_06.png

8、使用参数的画图

g8 = sns.jointplot("petal_length", "sepal_length", data=iris, marginal_kws=dict(bins=15, rug=True), 
                    annot_kws=dict(stat="r"), s=40, edgecolor="w", linewidth=1)
Seaborn-04-Jointplot两变量图_第7张图片
04_07.png

你可能感兴趣的:(Seaborn-04-Jointplot两变量图)