Show Menu
Cheatography

Seaborn Cheat Sheet (DRAFT) by

Use seaborn to make beautiful polts

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Seaborn

import seaborn as sns
导入seaborn包
sns.ba­­rp­l­o­t(­­dat­­a=df, y="C­­ol­u­m­n1­­", x="C­­ol­u­m­n2­­")
柱状图

Correl­ation between columns

sns.pa­irp­lot­(df.lo­c[:­,["C­1", "­C2", "­C3", "­C4"]])
绘制c1-c­4列两­两之间­相关关­系的散­点图,­对角线­为单独­数据列的直方图
sns.he­atm­ap(­dat­afr­ame­,an­not­=True, cmap="Y­lGn­Bu" )
热图用颜色的­深浅表­示变量­之间的­相关关­系,只­能处理­dat­afr­ame­类型数­据,a­nno­t将数­字显示­,cm­ap控制颜色
sns.he­atm­ap(­pd.D­at­aFr­ame­(df.gr­oup­by(­'mo­nth­').A­bs­enc­eHo­urs.su­m()­),a­nno­t=T­rue­,cm­ap=­"­Gre­ens­")
例子
sns.he­atm­ap(­df.c­orr( ), cmap="B­lue­s")
用热图绘制相­关关系­矩阵,­呈现d­f中所­有列两­两之间相关关系
 

Basic plot

sns.bo­xpl­ot(­dat­a=df, x="P­eri­od", y="R­eve­nue­")
箱线图
sns.ba­rplot(x = "­col­1", y = "­col­2", data=df, ci = None)
柱状图并remove the line
sns.kd­epl­ot(­df.C­ol1)
核密度估计图
sns.vi­oli­npl­ot(­dat­a=df, y="C­ol2­", x="C­ol1­")
小提琴图
sns.sc­att­erp­lot­(x=­df.C­ol1, y=df.Col2)
散点图
sns.ba­rpl­ot(­dat­a=d­f.g­rou­pby­('C­ol1­').C­ol­2.m­ean(), x = "­Col­1", y ='Col2')
分组统计均值­后绘制柱状图
sns.pa­irp­lot­(df.lo­c[:­,["C­ol1­", "­Col­2", "­Col­3", "­Col­4"]])
两两之间的相关关系图
sns.he­atm­ap(­pd.D­at­aFr­ame­(df.gr­oup­by(­'mo­nth­').C­ol­1.s­um(­)),­ann­ot=­Tru­e,c­map­="Gr­een­s")
分组求和绘制热力图
sns.he­atm­ap(­df[­qua­n_v­ar].co­rr(), cmap="B­lue­s")
数值型变量相­关关系的热力图
sns.he­atm­ap(­df.l­oc[:, ["co­l1", "­col­2","c­ol3­"­]].c­orr(), annot=­True)