线性关系数据可视化:lmplot()
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.set_style("whitegrid")
sns.set_context("paper")
import warnings
warnings.filterwarnings('ignore')
基本用法
tips = sns.load_dataset("tips")
tips.head()
sns.lmplot(x='total_bill', y='tip', hue='smoker', data=tips, palette='Set1',
ci=70,
size=5,
markers=['+','o'],
)
拆分多个表格
sns.lmplot(x='total_bill', y='tip', col='smoker', data=tips)
多图表1
sns.lmplot(x='size', y='total_bill', col='day', data=tips,
aspect=0.6,
x_jitter=0.3,
col_wrap=4
)
多图表2
sns.lmplot(x='total_bill', y='tip', row='sex', col='time', data=tips, size=4)
非线性回归
sns.lmplot(x='total_bill', y='tip', data=tips, order=3)
|