seaborn使用(绘图函数)

数据集分布的可视化

分类数据的绘图

线性关系可视化


一.数据集分布的可视化

  1. distplot
  2. kdeplot
  3. rugplot

1.distplot()

灵活的绘制单变量的分布,传入一组一维数据

默认kde为True,纵坐标为在横坐标区域内分布的概率,曲线表示概率密度函数,在区间上积分值为1

设置kde为False,纵坐标表示落在横坐标bins中的数值的数量

seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kws=None, kde_kws=None, rug_kws=None, fit_kws=None, color=None, vertical=False, norm_hist=False, axlabel=None, label=None, ax=None)

Parameters:

  • a:传入的一维数据
  • bins:控制直方图的竖直的长方形的数量
  • hist:是否绘制直方图
  • kde:是否绘制高斯和密度估计曲线
  • rug:是否在坐标轴上绘制rug
  • fit:An object with fit method, returning a tuple that can be passed to a pdf method a positional arguments following an grid of values to evaluate the pdf on.
  • color:设置颜色
  • vertical:设置为true,观察值在y轴
  • norm_hist:设置为true,直方图显示的是密度而不是count数
  • axlabel:Name for the support axis label
  • label:Legend label for the relevent component of the plot
  • ax:if provided, plot on this axis

    returns:
  • ax: matplotlib Axes.Returns the Axes object with the plot for further tweaking

2.kdeplot()

拟合或者绘画单元变量或者是双元变量的核密度估计

seaborn.kdeplot(data, data2=None, shade=False, vertical=False, kernel='gau', bw='scott', gridsize=100, cut=3, clip=None, legend=True, cumulative=False, shade_lowest=True, cbar=False, cbar_ax=None, cbar_kws=None, ax=None, **kwargs)

Parameters

  • data:Input data
  • data2:Second input data. If present, a bivariate KDE will be estimated.
  • shade:If True, shade in the area under the KDE curve (or draw with filled contours when data is bivariate)
  • vertical:If True, density is on x-axis
  • kernel:{‘gau’ | ‘cos’ | ‘biw’ | ‘epa’ | ‘tri’ | ‘triw’ } optional.

    Code for shape of kernel to fit with. Bivariate KDE can only use gaussian kernel.
  • bw:{‘scott’ | ‘silverman’ | scalar | pair of scalars }, optional

    Name of reference method to determine kernel size, scalar factor, or scalar for each dimension of the bivariate plot.
  • gridsize:int,optional.Number of discrete points in the evaluation grid.(评估网格中的离散点的数量)
  • cut:scalar,optional.Draw the estimate to cut * bw from the extreme data points.
  • clipt:Lower and upper bounds for datapoints used to fit KDE. Can provide a pair of (low, high) bounds for bivariate plots.定义上下界
  • legend:If True, add a legend or label the axes when possible.添加图例
  • cumulative:If True, draw the cumulative distribution estimated by the kde.累积概率密度
  • shade_lowest:If True, shade the lowest contour of a bivariate KDE plot. Not relevant when drawing a univariate plot or when shade=False. Setting this to False can be useful when you want multiple densities on the same Axes.
  • cbar:If True and drawing a bivariate KDE plot, add a colorbar.
  • cbar_ax:Existing axes to draw the colorbar onto, otherwise space is taken from the main axes.
  • cbar_kws:Keyword arguments for fig.colorbar().
  • ax:Axes to plot on, otherwise uses current axes.
  • kwargs:Other keyword arguments are passed to plt.plot() or plt.contour{f} depending on whether a univariate or bivariate plot is being drawn.

Returns

ax:Axes with plot


3.regplot()

绘制数据的散点分布并且可以进行线性回归模型拟合

seaborn.regplot(x, y, data=None, x_estimator=None, x_bins=None, x_ci='ci', scatter=True, fit_reg=True, ci=95, n_boot=1000, units=None, order=1, logistic=False, lowess=False, robust=False, logx=False, x_partial=None, y_partial=None, truncate=False, dropna=True, x_jitter=None, y_jitter=None, label=None, color=None, marker='o', scatter_kws=None, line_kws=None, ax=None)

patameters

  • x, y: string, series, or vector array

    Input variables. If strings, these should correspond with column names in data. When pandas objects are used, axes will be labeled with the series name.
  • data : DataFrame

    Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
  • x_estimator : callable that maps vector -> scalar, optional

    Apply this function to each unique value of x and plot the resulting estimate. This is useful when x is a discrete variable. If x_ci is given, this estimate will be bootstrapped and a confidence interval will be drawn.
  • x_bins : int or vector, optional

    Bin the x variable into discrete bins and then estimate the central tendency and a confidence interval. This binning only influences how the scatterplot is drawn; the regression is still fit to the original data. This parameter is interpreted either as the number of evenly-sized (not necessary spaced) bins or the positions of the bin centers. When this parameter is used, it implies that the default of x_estimator is numpy.mean.
  • x_ci : “ci”, “sd”, int in [0, 100] or None, optional

    Size of the confidence interval used when plotting a central tendency for discrete values of x. If "ci", defer to the value of the ci parameter. If "sd", skip bootstrappig and show the standard deviation of the observations in each bin.
  • scatter : bool, optional 是否绘制散点图

    If True, draw a scatterplot with the underlying observations (or the x_estimator values).
  • fit_reg : bool, optional 是否绘制拟合曲线

    If True, estimate and plot a regression model relating the x and y variables.
  • ci : int in [0, 100] or None, optional 回归估计的置信区间的大小

    Size of the confidence interval for the regression estimate. This will be drawn using translucent bands around the regression line. The confidence interval is estimated using a bootstrap; for large datasets, it may be advisable to avoid that computation by setting this parameter to None.
  • n_boot : int, optional

    Number of bootstrap resamples used to estimate the ci. The default value attempts to balance time and stability; you may want to increase this value for “final” versions of plots.
  • units : variable name in data, optional

    If the x and y observations are nested within sampling units, those can be specified here. This will be taken into account when computing the confidence intervals by performing a multilevel bootstrap that resamples both units and observations (within unit). This does not otherwise influence how the regression is estimated or drawn.
  • order : int, optional 如果order大于1,则用polyfit进行多项式回归

    If order is greater than 1, use numpy.polyfit to estimate a polynomial regression.
  • logistic : bool, optional 逻辑回归

    If True, assume that y is a binary variable and use statsmodels to estimate a logistic regression model. Note that this is substantially more computationally intensive than linear regression, so you may wish to decrease the number of bootstrap resamples (n_boot) or set ci to None.
  • lowess : bool, optional

    If True, use statsmodels to estimate a nonparametric lowess model (locally weighted linear regression). Note that confidence intervals cannot currently be drawn for this kind of model.
  • robust : bool, optional 减轻异常值,进行强回归

    If True, use statsmodels to estimate a robust regression. This will de-weight outliers. Note that this is substantially more computationally intensive than standard linear regression, so you may wish to decrease the number of bootstrap resamples (n_boot) or set ci to None.
  • logx : bool, optional y=log(x)的回归,x必须为正数

    If True, estimate a linear regression of the form y ~ log(x), but plot the scatterplot and regression model in the input space. Note that x must be positive for this to work.
  • {x,y}_partial : strings in data or matrices

    Confounding variables to regress out of the x or y variables before plotting.
  • truncate : bool, optional 截取一部分

    By default, the regression line is drawn to fill the x axis limits after the scatterplot is drawn. If truncate is True, it will instead by bounded by the data limits.
  • {x,y}_jitter : floats, optional 增加噪音值

    Add uniform random noise of this size to either the x or y variables. The noise is added to a copy of the data after fitting the regression, and only influences the look of the scatterplot. This can be helpful when plotting variables that take discrete values.
  • label : string

    Label to apply to ether the scatterplot or regression line (if scatter is False) for use in a legend.
  • color : matplotlib color

    Color to apply to all plot elements; will be superseded by colors passed in scatter_kws or line_kws.
  • marker : matplotlib marker code

    Marker to use for the scatterplot glyphs.
  • {scatter,line}_kws : dictionaries

    Additional keyword arguments to pass to plt.scatter and plt.plot.
  • ax : matplotlib Axes, optional

    Axes object to draw the plot onto, otherwise uses the current Axes.

Returns

ax : matplotlib Axes

The Axes object containing the plot

seaborn使用(绘图函数)的更多相关文章

  1. Matlab绘图函数一览

    要查看Matlab所有绘图函数,请从Matlab主界面菜单查看“绘图目录”,或从Matlab帮助文档查看“Types of MATLAB Plots”(在线版本).本文的图和英文解释摘自Matlab帮 ...

  2. 【《zw版·Halcon与delphi系列原创教程》Halcon图层与常用绘图函数

    [<zw版·Halcon与delphi系列原创教程>Halcon图层与常用绘图函数 Halcon的绘图函数,与传统编程vb.c.delphi语言完全不同,     传统编程语言,甚至cad ...

  3. R语言——基本绘图函数

    通过一个综合的例子测试绘图函数 学习的内容是tigerfish老师的教程. 第一节:基本知识 用seq函数产生100位学生的学号. > num = seq(,) > num [] [] [ ...

  4. 《MATLAB从入门到放弃》二维曲线和图形绘制基础(二):使用Help文档学习line、plot、plotyy、subplot、hold绘图函数

    目录: »  plot 最常用的二维曲线绘图函数 >  帮助文档 >  基本使用语法 >  线条的样式.符号和颜色调整 >  图形属性调整 >  使用图形句柄进行设置 » ...

  5. OpenCV中的绘图函数-OpenCV步步精深

    OpenCV 中的绘图函数 画线 首先要为画的线创造出环境,就要生成一个空的黑底图像 img=np.zeros((512,512,3), np.uint8) 这是黑色的底,我们的画布,我把窗口名叫做i ...

  6. 数据分析与展示——Matplotlib基础绘图函数示例

    Matplotlib库入门 Matplotlib基础绘图函数示例 pyplot基础图表函数概述 函数 说明 plt.plot(x,y,fmt, ...) 绘制一个坐标图 plt.boxplot(dat ...

  7. opencv学习之路(4)、Mat类介绍,基本绘图函数

    一.Mat类创建 Mat img;//创建无初始化矩阵 Mat img1(,,CV_8UC1);//200行,100列(长200,宽100) Mat img2(Size(,),CV_8UC3,Scal ...

  8. Matlab 二维绘图函数(plot类)

    plot 功能 绘制二维图形的最基本函数. 语法 //x为向量时,以x的元素值为纵坐标,x的序号为横坐标绘制曲线. //x为矩阵时,以其序号为横坐标,按列绘制每列元素值相对于其序号的曲线. polt( ...

  9. VS2010/MFC编程入门之四十九(图形图像:CDC类及其屏幕绘图函数)

    上一节中鸡啄米讲了文本输出的知识,本节的主要内容是CDC类及其屏幕绘图函数. CDC类简介 CDC类是一个设备上下文类. CDC类提供了用来处理显示器或打印机等设备上下文的成员函数,还有处理与窗口客户 ...

随机推荐

  1. Android:ImageView控件显示图片

    1)android显示图片可以使用imageView来呈现,而且也可以通过ImageButton来实现给button添加图片. 2)在创建一个ImageView后,显示图片绑定元素是:android: ...

  2. scrapy分布式的几个重点问题

    我们之前的爬虫都是在同一台机器运行的,叫做单机爬虫.scrapy的经典架构图也是描述的单机架构.那么分布式爬虫架构实际上就是:由一台主机维护所有的爬取队列,每台从机的sheduler共享该队列,协同存 ...

  3. Spring-Cloud(三)Eureka注册中心实现高可用

    前言: spring-cloud为基础的微服务架构,所有的微服务都需要注册到注册中心,如果这个注册中心阻塞或者崩了,那么整个系统都无法继续正常提供服务,所以,这里就需要对注册中心进行集群,换言之,高可 ...

  4. ES6关于Promise的用法

    Promise 对象用于一个异步操作的最终完成(或失败)及其结果值的表示.简单点说,它就是用于处理异步操作的,异步处理成功了就执行成功的操作,异步处理失败了就捕获错误或者停止后续操作. 它的一般表示形 ...

  5. [AHOI 2009]chess 中国象棋

    Description 题库链接 给你一张 \(N\times M\) 的棋盘.要求每行每列最多放两个棋子,问总方案数. \(1\leq N,M\leq 100\) Solution 记 \(f_{i ...

  6. [HEOI2015]小Z的房间

    Description 你突然有了一个大房子,房子里面有一些房间.事实上,你的房子可以看做是一个包含n*m个格子的格状矩形,每个格子是一个房间或者是一个柱子.在一开始的时候,相邻的格子之间都有墙隔着. ...

  7. [Wc2010]重建计划

    Description Input 第一行包含一个正整数N,表示X国的城市个数. 第二行包含两个正整数L和U,表示政策要求的第一期重建方案中修建道路数的上下限 接下来的N-1行描述重建小组的原有方案, ...

  8. 【bzoj4572 scoi2016】围棋

    题目描述 近日,谷歌研发的围棋AI—AlphaGo以4:1的比分战胜了曾经的世界冠军李世石,这是人工智能领域的又一里程碑. 与传统的搜索式AI不同,AlphaGo使用了最近十分流行的卷积神经网络模型. ...

  9. hdu 4052 线段树扫描线、奇特处理

    Adding New Machine Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  10. poj 1845 (逆元 + 约数和)

    题意: 求A^B的所有约数(即因子)之和,并对其取模 9901再输出. 思路: A可以表示为A=(p1^k1)*(p2^k2)*(p3^k3)*....*(pn^kn)   其中pi均为素数 那么A的 ...