直方图看数据分布
plt.figure(figsize=(12,5)) #默认图形 plt.subplot(141) sns.distplot(x) #不画直方图 plt.subplot(142) sns.distplot(x,hist=False) #不画线图 plt.subplot(143) sns.distplot(x,kde=False,bins=20) #设置fit plt.subplot(144) sns.distplot(x, kde=False, fit=stats.gamma)使用seaborn自带数据集进行分析
sns.jointplot(x="sepal_length", y="sepal_width", data=iris);当数据较多时,需要看数据聚集程度,可以用下面的方法
with sns.axes_style("white"): sns.jointplot(x="sepal_length", y="sepal_width", data=iris, kind="hex", color="k")查看所有变量之间的相关性
sns.pairplot(iris)factorplot是一封装了多种图形的函数
seaborn.factorplot(x=None, y=None, hue=None, data=None, row=None, col=None, col_wrap=None, estimator=, ci=95, n_boot=1000, units=None, order=None, hue_order=None, row_order=None, col_order=None, kind=‘point’, size=4, aspect=1, orient=None, color=None, palette=None, legend=True, legend_out=True, sharex=True, sharey=True, margin_titles=False, facet_kws=None, **kwargs)
x,y,hue 数据集变量 变量名date 数据集 数据集名row,col 更多分类变量进行平铺显示 变量名col_wrap 每行的最高平铺数 整数estimator 在每个分类中进行矢量到标量的映射 矢量ci 置信区间 浮点数或Nonen_boot 计算置信区间时使用的引导迭代次数 整数units 采样单元的标识符,用于执行多级引导和重复测量设计 数据变量或向量数据order, hue_order 对应排序列表 字符串列表row_order, col_order 对应排序列表 字符串列表kind : 可选:point 默认, bar 柱形图, count 频次, box 箱体, violin 提琴, strip 散点,swarm 分散点 size 每个面的高度(英寸) 标量 aspect 纵横比 标量 orient 方向 “v”/“h” color 颜色 matplotlib颜色 palette 调色板 seaborn颜色色板或字典 legend hue的信息面板 True/False legend_out 是否扩展图形,并将信息框绘制在中心右边 True/False share{x,y} 共享轴线 True/Falseexample
#盒图 sns.factorplot(x="time", y="total_bill", hue="smoker", col="day", data=tips, kind="box", size=4, aspect=.5)