目录
方法签名
参数
kind
hue
style
size
seaborn.relplot(x=None, y=None, hue=None, size=None, style=None, data=None, row=None, col=None, col_wrap=None, row_order=None, col_order=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, markers=None, dashes=None, style_order=None, legend='brief', kind='scatter', height=5, aspect=1, facet_kws=None, **kwargs)
这里要小结的参数有 hue, style, size, kind, col, 主要是自己从官方文档中阅读/理解而来, 方便以后查看.
加载数据集:
import matplotlib.pyplot as plt
import seaborn as sns
fmri = sns.load_dataset("fmri")
数据样例:
subject timepoint event region signal
0 s13 18 stim parietal -0.017552
1 s5 14 stim parietal -0.080883
2 s12 18 stim parietal -0.081033
3 s11 18 stim parietal -0.046134
4 s10 18 stim parietal -0.037970
kindle: 取值为 line 或者 scatter, 后者为默认值 .
1) kind=line时作图
sns.relplot(x="timepoint", y="signal", kind="line", data=fmri)
*注: 阴影部分是由于纵坐标上多个值导致的, 取值为均值, 阴影部分是置信区间.
此时, 可以通过ci (confidence interval)参数来控制阴影部分, ci=None
sns.relplot(x="timepoint", y="signal",ci=None, kind="line", data=fmri)
当然, ci也可以采用其他算法, 如'td'
sns.relplot(x="timepoint", y="signal", ci="sd", kind="line", data=fmri)
也可以关闭数据聚合功能(urn off aggregation altogether), 设置estimator=None即可.
2) kind=scatter时作图
sns.relplot(x="timepoint", y="signal", kind="scatter", data=fmri)
hue: 在某一维度上, 用颜色区分;
style: 在某一维度上, 线的表现形式不同, 如 点线, 虚线等;
size: 控制数据点大小或者线条粗细.
1) kind=line
sns.relplot(x="timepoint", y="signal", kind="line",size="subject", data=fmri)
2) kind=scatter
来自
[1] http://seaborn.pydata.org/tutorial/relational.html#relational-tutorial