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")

04_01.png

3、回归图

g3 = sns.jointplot("total_bill", "tip", data=tips, kind="reg")

04_02.png

4、六角图

g4 = sns.jointplot("total_bill", "tip", data=tips, kind="hex")

04_03.png

5、KDE 图

g5 = sns.jointplot("total_bill", "tip", data=tips, kind="kde", space=0, color="#6AB27B")

04_04.png

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

g6 = sns.jointplot("size", "total_bill", data=tips, color="#8172B2")

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))

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)

04_07.png

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值