未验证 提交 e235e972 编写于 作者: 飞龙 提交者: GitHub

Merge branch 'master' into master

......@@ -5,10 +5,15 @@
> 欢迎任何人参与和完善:一个人可以走的很快,但是一群人却可以走的更远。
* [在线阅读](https://apachecn.github.io/seaborn-doc-zh)
* [贡献指南](CONTRIBUTING.md)
* [ApacheCN 机器学习交流群 629470233](http://shang.qq.com/wpa/qunwpa?idkey=30e5f1123a79867570f665aa3a483ca404b1c3f77737bc01ec520ed5f078ddef)
* [ApacheCN 学习资源](http://www.apachecn.org/)
## 贡献指南
项目当前处于翻译阶段,请查看[贡献指南](CONTRIBUTING.md),并在[整体进度](https://github.com/apachecn/seaborn-doc-zh/issues/1)中领取任务。
> 请您勇敢地去翻译和改进翻译。虽然我们追求卓越,但我们并不要求您做到十全十美,因此请不要担心因为翻译上犯错——在大部分情况下,我们的服务器已经记录所有的翻译,因此您不必担心会因为您的失误遭到无法挽回的破坏。(改编自维基百科)
## 联系方式
### 负责人
......
......@@ -21,94 +21,92 @@ After plotting, the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seab
Note that, unlike when using the underlying plotting functions directly, data must be passed in a long-form DataFrame with variables specified by passing strings to `x`, `y`, and other parameters.
| Parameters: | **x, y** : names of variables in `data`
参数:`x, y`names of variables in `data`
> Input data variables; must be numeric.
**hue** : name in `data`, optional
`hue`name in `data`, optional
> Grouping variable that will produce elements with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
**size** : name in `data`, optional
`size`name in `data`, optional
> Grouping variable that will produce elements with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter case.
**style** : name in `data`, optional
`style`name in `data`, optional
> Grouping variable that will produce elements with different styles. Can have a numeric dtype but will always be treated as categorical.
**data** : DataFrame
`data`DataFrame
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
**row, col** : names of variables in `data`, optional
`row, col`names of variables in `data`, optional
> Categorical variables that will determine the faceting of the grid.
**col_wrap** : int, optional
`col_wrap`int, optional
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
**row_order, col_order** : lists of strings, optional
`row_order, col_order`lists of strings, optional
> Order to organize the rows and/or columns of the grid in, otherwise the orders are inferred from the data objects.
**palette** : palette name, list, or dict, optional
`palette`palette name, list, or dict, optional
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
**hue_order** : list, optional
`hue_order`list, optional
> Specified order for the appearance of the `hue` variable levels, otherwise they are determined from the data. Not relevant when the `hue` variable is numeric.
**hue_norm** : tuple or Normalize object, optional
`hue_norm`tuple or Normalize object, optional
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
**sizes** : list, dict, or tuple, optional
`sizes`list, dict, or tuple, optional
> An object that determines how sizes are chosen when `size` is used. It can always be a list of size values or a dict mapping levels of the `size` variable to sizes. When `size` is numeric, it can also be a tuple specifying the minimum and maximum size to use such that other values are normalized within this range.
**size_order** : list, optional
`size_order`list, optional
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
**size_norm** : tuple or Normalize object, optional
`size_norm`tuple or Normalize object, optional
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
**legend** : “brief”, “full”, or False, optional
`legend`“brief”, “full”, or False, optional
> How to draw the legend. If “brief”, numeric `hue` and `size` variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If `False`, no legend data is added and no legend is drawn.
**kind** : string, optional
`kind`string, optional
> Kind of plot to draw, corresponding to a seaborn relational plot. Options are {`scatter` and `line`}.
**height** : scalar, optional
`height`scalar, optional
> Height (in inches) of each facet. See also: `aspect`.
**aspect** : scalar, optional
`aspect`scalar, optional
> Aspect ratio of each facet, so that `aspect * height` gives the width of each facet in inches.
**facet_kws** : dict, optional
`facet_kws`dict, optional
> Dictionary of other keyword arguments to pass to [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid").
**kwargs** : key, value pairings
`kwargs`key, value pairings
> Other keyword arguments are passed through to the underlying plotting function.
|
| --- | --- |
| Returns: | **g** : [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")
返回值:`g`[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")
> Returns the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") object with the plot on it for further tweaking.
|
| --- | --- |
Examples
......
......@@ -10,108 +10,106 @@ The relationship between `x` and `y` can be shown for different subsets of the d
See the [tutorial](../tutorial/relational.html#relational-tutorial) for more information.
| Parameters: | **x, y** : names of variables in `data` or vector data, optional
参数:`x, y`names of variables in `data` or vector data, optional
> Input data variables; must be numeric. Can pass data directly or reference columns in `data`.
**hue** : name of variables in `data` or vector data, optional
`hue`name of variables in `data` or vector data, optional
> Grouping variable that will produce points with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
**size** : name of variables in `data` or vector data, optional
`size`name of variables in `data` or vector data, optional
> Grouping variable that will produce points with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter case.
**style** : name of variables in `data` or vector data, optional
`style`name of variables in `data` or vector data, optional
> Grouping variable that will produce points with different markers. Can have a numeric dtype but will always be treated as categorical.
**data** : DataFrame
`data`DataFrame
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
**palette** : palette name, list, or dict, optional
`palette`palette name, list, or dict, optional
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
**hue_order** : list, optional
`hue_order`list, optional
> Specified order for the appearance of the `hue` variable levels, otherwise they are determined from the data. Not relevant when the `hue` variable is numeric.
**hue_norm** : tuple or Normalize object, optional
`hue_norm`tuple or Normalize object, optional
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
**sizes** : list, dict, or tuple, optional
`sizes`list, dict, or tuple, optional
> An object that determines how sizes are chosen when `size` is used. It can always be a list of size values or a dict mapping levels of the `size` variable to sizes. When `size` is numeric, it can also be a tuple specifying the minimum and maximum size to use such that other values are normalized within this range.
**size_order** : list, optional
`size_order`list, optional
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
**size_norm** : tuple or Normalize object, optional
`size_norm`tuple or Normalize object, optional
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
**markers** : boolean, list, or dictionary, optional
`markers`boolean, list, or dictionary, optional
> Object determining how to draw the markers for different levels of the `style` variable. Setting to `True` will use default markers, or you can pass a list of markers or a dictionary mapping levels of the `style` variable to markers. Setting to `False` will draw marker-less lines. Markers are specified as in matplotlib.
**style_order** : list, optional
`style_order`list, optional
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
**{x,y}_bins** : lists or arrays or functions
`{x,y}_bins`lists or arrays or functions
> _Currently non-functional._
**units** : {long_form_var}
`units`{long_form_var}
> Grouping variable identifying sampling units. When used, a separate line will be drawn for each unit with appropriate semantics, but no legend entry will be added. Useful for showing distribution of experimental replicates when exact identities are not needed.
>
> _Currently non-functional._
**estimator** : name of pandas method or callable or None, optional
`estimator`name of pandas method or callable or None, optional
> Method for aggregating across multiple observations of the `y` variable at the same `x` level. If `None`, all observations will be drawn. _Currently non-functional._
**ci** : int or “sd” or None, optional
`ci`int or “sd” or None, optional
> Size of the confidence interval to draw when aggregating with an estimator. “sd” means to draw the standard deviation of the data. Setting to `None` will skip bootstrapping. _Currently non-functional._
**n_boot** : int, optional
`n_boot`int, optional
> Number of bootstraps to use for computing the confidence interval. _Currently non-functional._
**alpha** : float
`alpha`float
> Proportional opacity of the points.
**{x,y}_jitter** : booleans or floats
`{x,y}_jitter`booleans or floats
> _Currently non-functional._
**legend** : “brief”, “full”, or False, optional
`legend`“brief”, “full”, or False, optional
> How to draw the legend. If “brief”, numeric `hue` and `size` variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If `False`, no legend data is added and no legend is drawn.
**ax** : matplotlib Axes, optional
`ax`matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
**kwargs** : key, value mappings
`kwargs`key, value mappings
> Other keyword arguments are passed down to `plt.scatter` at draw time.
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
......
......@@ -12,110 +12,108 @@ See the [tutorial](../tutorial/relational.html#relational-tutorial) for more inf
By default, the plot aggregates over multiple `y` values at each value of `x` and shows an estimate of the central tendency and a confidence interval for that estimate.
| Parameters: | **x, y** : names of variables in `data` or vector data, optional
参数:`x, y`names of variables in `data` or vector data, optional
> Input data variables; must be numeric. Can pass data directly or reference columns in `data`.
**hue** : name of variables in `data` or vector data, optional
`hue`name of variables in `data` or vector data, optional
> Grouping variable that will produce lines with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
**size** : name of variables in `data` or vector data, optional
`size`name of variables in `data` or vector data, optional
> Grouping variable that will produce lines with different widths. Can be either categorical or numeric, although size mapping will behave differently in latter case.
**style** : name of variables in `data` or vector data, optional
`style`name of variables in `data` or vector data, optional
> Grouping variable that will produce lines with different dashes and/or markers. Can have a numeric dtype but will always be treated as categorical.
**data** : DataFrame
`data`DataFrame
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
**palette** : palette name, list, or dict, optional
`palette`palette name, list, or dict, optional
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
**hue_order** : list, optional
`hue_order`list, optional
> Specified order for the appearance of the `hue` variable levels, otherwise they are determined from the data. Not relevant when the `hue` variable is numeric.
**hue_norm** : tuple or Normalize object, optional
`hue_norm`tuple or Normalize object, optional
> Normalization in data units for colormap applied to the `hue` variable when it is numeric. Not relevant if it is categorical.
**sizes** : list, dict, or tuple, optional
`sizes`list, dict, or tuple, optional
> An object that determines how sizes are chosen when `size` is used. It can always be a list of size values or a dict mapping levels of the `size` variable to sizes. When `size` is numeric, it can also be a tuple specifying the minimum and maximum size to use such that other values are normalized within this range.
**size_order** : list, optional
`size_order`list, optional
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
**size_norm** : tuple or Normalize object, optional
`size_norm`tuple or Normalize object, optional
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
**dashes** : boolean, list, or dictionary, optional
`dashes`boolean, list, or dictionary, optional
> Object determining how to draw the lines for different levels of the `style` variable. Setting to `True` will use default dash codes, or you can pass a list of dash codes or a dictionary mapping levels of the `style` variable to dash codes. Setting to `False` will use solid lines for all subsets. Dashes are specified as in matplotlib: a tuple of `(segment, gap)` lengths, or an empty string to draw a solid line.
**markers** : boolean, list, or dictionary, optional
`markers`boolean, list, or dictionary, optional
> Object determining how to draw the markers for different levels of the `style` variable. Setting to `True` will use default markers, or you can pass a list of markers or a dictionary mapping levels of the `style` variable to markers. Setting to `False` will draw marker-less lines. Markers are specified as in matplotlib.
**style_order** : list, optional
`style_order`list, optional
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
**units** : {long_form_var}
`units`{long_form_var}
> Grouping variable identifying sampling units. When used, a separate line will be drawn for each unit with appropriate semantics, but no legend entry will be added. Useful for showing distribution of experimental replicates when exact identities are not needed.
**estimator** : name of pandas method or callable or None, optional
`estimator`name of pandas method or callable or None, optional
> Method for aggregating across multiple observations of the `y` variable at the same `x` level. If `None`, all observations will be drawn.
**ci** : int or “sd” or None, optional
`ci`int or “sd” or None, optional
> Size of the confidence interval to draw when aggregating with an estimator. “sd” means to draw the standard deviation of the data. Setting to `None` will skip bootstrapping.
**n_boot** : int, optional
`n_boot`int, optional
> Number of bootstraps to use for computing the confidence interval.
**sort** : boolean, optional
`sort`boolean, optional
> If True, the data will be sorted by the x and y variables, otherwise lines will connect points in the order they appear in the dataset.
**err_style** : “band” or “bars”, optional
`err_style`“band” or “bars”, optional
> Whether to draw the confidence intervals with translucent error bands or discrete error bars.
**err_band** : dict of keyword arguments
`err_band`dict of keyword arguments
> Additional paramters to control the aesthetics of the error bars. The kwargs are passed either to `ax.fill_between` or `ax.errorbar`, depending on the `err_style`.
**legend** : “brief”, “full”, or False, optional
`legend`“brief”, “full”, or False, optional
> How to draw the legend. If “brief”, numeric `hue` and `size` variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If `False`, no legend data is added and no legend is drawn.
**ax** : matplotlib Axes, optional
`ax`matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
**kwargs** : key, value mappings
`kwargs`key, value mappings
> Other keyword arguments are passed down to `plt.plot` at draw time.
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
......
# seaborn.catplot
> 译者:[LIJIANcoder97](https://github.com/LIJIANcoder97)
```py
seaborn.catplot(x=None, y=None, hue=None, data=None, row=None, col=None, col_wrap=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, order=None, hue_order=None, row_order=None, col_order=None, kind='strip', height=5, aspect=1, orient=None, color=None, palette=None, legend=True, legend_out=True, sharex=True, sharey=True, margin_titles=False, facet_kws=None, **kwargs)
```
Figure-level interface for drawing categorical plots onto a FacetGrid.
seaborn.catplot 是一个将分类图绘制到FacetGrid上图级别接口。
This function provides access to several axes-level functions that show the relationship between a numerical and one or more categorical variables using one of several visual representations. The `kind` parameter selects the underlying axes-level function to use:
这个函数可以访问多个轴级功能,这些轴级功能通过不同的可视化图表展示数字和一个或多个分类变量的关系。`kind` 参数可以选择的轴级基础函数有:
Categorical scatterplots:
分类散点图:
* [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot") (with `kind="strip"`; the default)
* [`swarmplot()`](seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot") (with `kind="swarm"`)
Categorical distribution plots:
分类分布图:
* [`boxplot()`](seaborn.boxplot.html#seaborn.boxplot "seaborn.boxplot") (with `kind="box"`)
* [`violinplot()`](seaborn.violinplot.html#seaborn.violinplot "seaborn.violinplot") (with `kind="violin"`)
* [`boxenplot()`](seaborn.boxenplot.html#seaborn.boxenplot "seaborn.boxenplot") (with `kind="boxen"`)
Categorical estimate plots:
分类估计图:
* [`pointplot()`](seaborn.pointplot.html#seaborn.pointplot "seaborn.pointplot") (with `kind="point"`)
* [`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot") (with `kind="bar"`)
* [`countplot()`](seaborn.countplot.html#seaborn.countplot "seaborn.countplot") (with `kind="count"`)
Extra keyword arguments are passed to the underlying function, so you should refer to the documentation for each to see kind-specific options.
额外的关键字参数将传递给基础函数,因此,您应参阅每个文档,以查看特定类型的选项.
请注意,与直接使用轴级函数不同, 数据必须在长格式DataFrame中传递,并通过将字符串传递给 `x`, `y`, `hue`, 等指定的变量.
与基础绘图函数的情况一样, 如果变量有 `categorical` 数据类型, 则将从对象推断出分类变量的级别及其顺序。否则,您可能必须使用更改 dataframe 排序或使用函数参数(`orient`, `order`, `hue_order`, etc.) 来正确设置绘图。
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型。
Note that unlike when using the axes-level functions directly, data must be passed in a long-form DataFrame with variables specified by passing strings to `x`, `y`, `hue`, etc.
有关更多信息,请参考 [tutorial](../tutorial/categorical.html#categorical-tutorial)
As in the case with the underlying plot functions, if variables have a `categorical` data type, the the levels of the categorical variables, and their order will be inferred from the objects. Otherwise you may have to use alter the dataframe sorting or use the function parameters (`orient`, `order`, `hue_order`, etc.) to set up the plot correctly.
绘图后,返回带有绘图的 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"),可以直接用于调整绘图细节或添加其他图层。
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
参数:`x, y, hue``data` names 中的变量名称
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
> 用于绘制长格式数据的输入。查看解释示例
After plotting, the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") with the plot is returned and can be used directly to tweak supporting plot details or add other layers.
`data`:DataFrame
| Parameters: | **x, y, hue** : names of variables in `data`
> 用于绘图的长形(整洁)数据集。每列应对应一个变量,每行应对应一个观察。
> Inputs for plotting long-form data. See examples for interpretation.
`row, col``data` 中的变量名称, 可选
**data** : DataFrame
> 分类变量将决定网格的分面。
> Long-form (tidy) dataset for plotting. Each column should correspond to a variable, and each row should correspond to an observation.
`col_wrap`:int, 可选
**row, col** : names of variables in `data`, optional
> 以此宽度“包裹”列变量,以便列面跨越多行。 与`行`方面不兼容。
> Categorical variables that will determine the faceting of the grid.
`estimator`:可调用的映射向量 -&gt; 标量,可选
**col_wrap** : int, optional
> 在每个分类箱内估计的统计函数。
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
`ci`:float或“sd”或None,可选
**estimator** : callable that maps vector -&gt; scalar, optional
> 在估计值附近绘制置信区间的大小。如果是“sd”,则跳过自举(bootstrapping)并绘制观察的标准偏差。None,如果为`None`,则不执行自举,并且不会绘制错误条。
> Statistical function to estimate within each categorical bin.
`n_boot`:int,可选
**ci** : float or “sd” or None, optional
> 计算置信区间时使用的引导程序迭代次数。
> Size of confidence intervals to draw around estimated values. If “sd”, skip bootstrapping and draw the standard deviation of the observations. If `None`, no bootstrapping will be performed, and error bars will not be drawn.
`units``数据`或矢量数据中变量的名称,可选
**n_boot** : int, optional
>采样单元的标识符,用于执行多级引导程序并考虑重复测量设计。
> Number of bootstrap iterations to use when computing confidence intervals.
`order, hue_order`:字符串列表,可选
**units** : name of variable in `data` or vector data, optional
> 命令绘制分类级别,否则从数据对象推断级别。
> Identifier of sampling units, which will be used to perform a multilevel bootstrap and account for repeated measures design.
`row_order, col_order`:字符串列表,可选
**order, hue_order** : lists of strings, optional
>命令组织网格的行和/或列,否则从数据对象推断命令。
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
`kind`:字符串,可选
**row_order, col_order** : lists of strings, optional
>要绘制的绘图类型(对应于分类绘图功能的名称。选项包括:“点”,“条形”,“条形”,“群”,“框”,“小提琴”或“盒子”。
> Order to organize the rows and/or columns of the grid in, otherwise the orders are inferred from the data objects.
`height`:标量,可选
**kind** : string, optional
> 每个刻面的高度(以英寸为单位)。另见: `aspect`。
> The kind of plot to draw (corresponds to the name of a categorical plotting function. Options are: “point”, “bar”, “strip”, “swarm”, “box”, “violin”, or “boxen”.
`aspect`:标量,可选
**height** : scalar, optional
> 每个面的纵横比,因此`aspect * height`给出每个面的宽度,单位为英寸。
> Height (in inches) of each facet. See also: `aspect`.
`orient`:“v” &#124; “h”, 可选
**aspect** : scalar, optional
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> Aspect ratio of each facet, so that `aspect * height` gives the width of each facet in inches.
`color`:matplotlib颜色,可选
**orient** : “v” &#124; “h”, optional
> 所有元素的颜色,或渐变调色板的种子。
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
`palette`:调色板名称,列表或字典,可选
**color** : matplotlib color, optional
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> Color for all of the elements, or seed for a gradient palette.
`legend`:bool, 可选
**palette** : palette name, list, or dict, optional
> 如果为 `True` 并且存在`hue`变量,则在图上绘制图例。t.
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
`legend_out`:bool, 可选
**legend** : bool, optional
> 如果为`True`,则图形尺寸将被扩展,图例将绘制在中间右侧的图形之外。
> If `True` and there is a `hue` variable, draw a legend on the plot.
**legend_out** : bool, optional
`share{x,y}`:bool, ‘col’, 或 ‘row’ 可选
> If `True`, the figure size will be extended, and the legend will be drawn outside the plot on the center right.
> 如果为true,则facet将跨行跨越列和/或x轴共享y轴。
**share{x,y}** : bool, ‘col’, or ‘row’ optional
`margin_titles`:bool, 可选
> If true, the facets will share y axes across columns and/or x axes across rows.
> 如果为`True`,则行变量的标题将绘制在最后一列的右侧。此选项是实验性的,可能无法在所有情况下使用。
**margin_titles** : bool, optional
`facet_kws`:dict, 可选
> If `True`, the titles for the row variable are drawn to the right of the last column. This option is experimental and may not work in all cases.
> 传递给[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的其他关键字参数的字典。
**facet_kws** : dict, optional
`kwargs`:key, value 配对
> Dictionary of other keyword arguments to pass to [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid").
> 其他关键字参数将传递给基础绘图函数。
**kwargs** : key, value pairings
> Other keyword arguments are passed through to the underlying plotting function.
返回值:`g`[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")
|
| --- | --- |
| Returns: | **g** : [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")
> 返回[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")对象及其上的绘图以进一步调整。
> Returns the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") object with the plot on it for further tweaking.
|
| --- | --- |
Examples
例子
Draw a single facet to use the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") legend placement:
绘制单个构面以使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")图例放置:
```py
>>> import seaborn as sns
......@@ -148,7 +149,7 @@ Draw a single facet to use the [`FacetGrid`](seaborn.FacetGrid.html#seaborn.Face
![http://seaborn.pydata.org/_images/seaborn-catplot-1.png](img/0b12363978e10369fc98bd33cb536d85.jpg)
Use a different plot kind to visualize the same data:
使用不同的绘图类型可视化相同的数据:
```py
>>> g = sns.catplot(x="time", y="pulse", hue="kind",
......@@ -158,7 +159,7 @@ Use a different plot kind to visualize the same data:
![http://seaborn.pydata.org/_images/seaborn-catplot-2.png](img/edd1fe3b83d3ec7ff2a1310bc2b87b8c.jpg)
Facet along the columns to show a third categorical variable:
沿列的方面显示第三个分类变量:
```py
>>> g = sns.catplot(x="time", y="pulse", hue="kind",
......@@ -168,7 +169,7 @@ Facet along the columns to show a third categorical variable:
![http://seaborn.pydata.org/_images/seaborn-catplot-3.png](img/f54e97484ce6dfcae6e1ceafe18503af.jpg)
Use a different height and aspect ratio for the facets:
为构面使用不同的高度和宽高比:
```py
>>> g = sns.catplot(x="time", y="pulse", hue="kind",
......@@ -179,7 +180,7 @@ Use a different height and aspect ratio for the facets:
![http://seaborn.pydata.org/_images/seaborn-catplot-4.png](img/ff09acb1a4ecf2c617aa1323f8894fe5.jpg)
Make many column facets and wrap them into the rows of the grid:
创建许多列构面并将它们包装到网格的行中:
```py
>>> titanic = sns.load_dataset("titanic")
......@@ -191,7 +192,7 @@ Make many column facets and wrap them into the rows of the grid:
![http://seaborn.pydata.org/_images/seaborn-catplot-5.png](img/94e545c07037b66573b94c5d43e41899.jpg)
Plot horizontally and pass other keyword arguments to the plot function:
水平绘图并将其他关键字参数传递给绘图函数:
```py
>>> g = sns.catplot(x="age", y="embark_town",
......@@ -204,7 +205,7 @@ Plot horizontally and pass other keyword arguments to the plot function:
![http://seaborn.pydata.org/_images/seaborn-catplot-6.png](img/141f4c98341da1bc3beb4dc78e30df08.jpg)
Use methods on the returned [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") to tweak the presentation:
使用返回的[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 上的方法来调整演示文稿:
```py
>>> g = sns.catplot(x="who", y="survived", col="class",
......@@ -219,4 +220,4 @@ Use methods on the returned [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGr
```
![http://seaborn.pydata.org/_images/seaborn-catplot-7.png](img/407bdac663f0df796492a65e635fca81.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-catplot-7.png](img/407bdac663f0df796492a65e635fca81.jpg)
# seaborn.stripplot
> 译者:[LIJIANcoder97](https://github.com/LIJIANcoder97)
```py
seaborn.stripplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, jitter=True, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)
```
Draw a scatterplot where one variable is categorical.
绘制一个散点图,其中一个变量是分类。
条形图可以单独绘制,但如果您想要显示所有观察结果以及底层分布的某些表示,它也是一个盒子或小提琴图的良好补充。
A strip plot can be drawn on its own, but it is also a good complement to a box or violin plot in cases where you want to show all observations along with some representation of the underlying distribution.
输入数据可以以多种格式传递,包括:
Input data can be passed in a variety of formats, including:
* 表示为列表,numpy数组或pandas Series对象的数据向量直接传递给`x``y``hue`参数
* 在这种情况下,`x``y``hue`变量将决定数据的绘制方式。
* “wide-form” DataFrame, 用于绘制每个数字列。
* 一个数组或向量列表。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
在大多数情况下,可以使用numpy或Python对象,但最好使用pandas对象,因为关联的名称将用于注释轴。另外,您可以使用分组变量的分类类型来控制绘图元素的顺序。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型也是如此。
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
有关更多信息,请参阅[教程](../tutorial/categorical.html#categorical-tutorial)
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
参数:`x, y, hue``数据`或矢量数据中的变量名称,可选
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
> 用于绘制长格式数据的输入。查看解释示例。
> Inputs for plotting long-form data. See examples for interpretation.
`data`:DataFrame, 数组, 数组列表, 可选
**data** : DataFrame, array, or list of arrays, optional
>用于绘图的数据集。如果 `x` 和 `y` 不存在,则将其解释为宽格式。否则预计它将是长格式的。
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
`order, hue_order`:字符串列表,可选
**order, hue_order** : lists of strings, optional
>命令绘制分类级别,否则从数据对象推断级别。
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
`jitter`:float, `True`/`1` 是特殊的,可选
**jitter** : float, `True`/`1` is special-cased, optional
>要应用的抖动量(仅沿分类轴)。 当您有许多点并且它们重叠时,这可能很有用,因此更容易看到分布。您可以指定抖动量(均匀随机变量支持的宽度的一半),或者仅使用`True`作为良好的默认值
> Amount of jitter (only along the categorical axis) to apply. This can be useful when you have many points and they overlap, so that it is easier to see the distribution. You can specify the amount of jitter (half the width of the uniform random variable support), or just use `True` for a good default.
`dodge`:bool, 可选
**dodge** : bool, optional
>使用 `hue` 嵌套时,将其设置为 `True` 将沿着分类轴分离不同色调级别的条带。否则,每个级别的点将相互叠加。
> When using `hue` nesting, setting this to `True` will separate the strips for different hue levels along the categorical axis. Otherwise, the points for each level will be plotted on top of each other.
`orient`:“v” &#124; “h”, 可选
**orient** : “v” &#124; “h”, optional
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
`color`:matplotlib颜色,可选
**color** : matplotlib color, optional
> 所有元素的颜色,或渐变调色板的种子。
> Color for all of the elements, or seed for a gradient palette.
`palette`:调色板名称,列表或字典,可选
**palette** : palette name, list, or dict, optional
> 用于色调变量的不同级别的颜色。应该是 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
`size`:float, 可选
**size** : float, optional
> 标记的直径,以磅为单位。(虽然 `plt.scatter` 用于绘制点,但这里的 `size` 参数采用“普通”标记大小而不是大小^ 2,如 `plt.scatter` 。
> Diameter of the markers, in points. (Although `plt.scatter` is used to draw the points, the `size` argument here takes a “normal” markersize and not size^2 like `plt.scatter`.
`edgecolor`:matplotlib颜色,“灰色”是特殊的,可选的
**edgecolor** : matplotlib color, “gray” is special-cased, optional
>每个点周围线条的颜色。如果传递`"灰色"`,则亮度由用于点体的调色板决定。
> Color of the lines around each point. If you pass `"gray"`, the brightness is determined by the color palette used for the body of the points.
`linewidth`:float, 可选
**linewidth** : float, optional
> 构图元素的灰线宽度。
> Width of the gray lines that frame the plot elements.
`ax`:matplotlib轴,可选
**ax** : matplotlib Axes, optional
> 返回Axes对象,并在其上绘制绘图。
> Axes object to draw the plot onto, otherwise uses the current Axes.
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib轴
> Returns the Axes object with the plot drawn onto it.
> 返回Axes对象,并在其上绘制绘图。
|
| --- | --- |
See also
A categorical scatterplot where the points do not overlap. Can be used with other plots to show each observation.A traditional box-and-whisker plot with a similar API.A combination of boxplot and kernel density estimation.
也可参看
Examples
分类散点图,其中点不重叠。可以与其他图一起使用来显示每个观察结果。带有类似API的传统盒须图。箱形图和核密度估计的组合。
Draw a single horizontal strip plot:
例子
绘制单个水平条形图:
```py
>>> import seaborn as sns
......@@ -96,7 +96,7 @@ Draw a single horizontal strip plot:
![http://seaborn.pydata.org/_images/seaborn-stripplot-1.png](img/23f314e72f6e5a8952dc9e9ad7e91951.jpg)
Group the strips by a categorical variable:
通过分类变量对条形图进行分组:
```py
>>> ax = sns.stripplot(x="day", y="total_bill", data=tips)
......@@ -105,7 +105,7 @@ Group the strips by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-stripplot-2.png](img/e91e31fb6bd4af0c4a7726101c5498d5.jpg)
Add jitter to bring out the distribution of values:
添加抖动以显示值的分布:
```py
>>> ax = sns.stripplot(x="day", y="total_bill", data=tips, jitter=True)
......@@ -114,7 +114,7 @@ Add jitter to bring out the distribution of values:
![http://seaborn.pydata.org/_images/seaborn-stripplot-3.png](img/bb509cea6c5bc79011b7aae3d06f02af.jpg)
Use a smaller amount of jitter:
使用较少量的抖动:
```py
>>> ax = sns.stripplot(x="day", y="total_bill", data=tips, jitter=0.05)
......@@ -123,7 +123,7 @@ Use a smaller amount of jitter:
![http://seaborn.pydata.org/_images/seaborn-stripplot-4.png](img/187d29ea70c79f73b11ccc7bfa3d2dc3.jpg)
Draw horizontal strips:
画水平条形图:
```py
>>> ax = sns.stripplot(x="total_bill", y="day", data=tips,
......@@ -133,7 +133,7 @@ Draw horizontal strips:
![http://seaborn.pydata.org/_images/seaborn-stripplot-5.png](img/3f587e4b0523d3c3e09d9950a187d53c.jpg)
Draw outlines around the points:
围绕要点绘制轮廓:
```py
>>> ax = sns.stripplot(x="total_bill", y="day", data=tips,
......@@ -143,7 +143,7 @@ Draw outlines around the points:
![http://seaborn.pydata.org/_images/seaborn-stripplot-6.png](img/808d1fbb36b6a8028b4e31ec238af4dc.jpg)
Nest the strips within a second categorical variable:
将条带嵌套在第二个分类变量中:
```py
>>> ax = sns.stripplot(x="sex", y="total_bill", hue="day",
......@@ -153,7 +153,7 @@ Nest the strips within a second categorical variable:
![http://seaborn.pydata.org/_images/seaborn-stripplot-7.png](img/6667c226e573f81913cd01ab631ca098.jpg)
Draw each level of the `hue` variable at different locations on the major categorical axis:
在主要分类轴上的不同位置绘制 `hue` 变量的每个级别:
```py
>>> ax = sns.stripplot(x="day", y="total_bill", hue="smoker",
......@@ -164,7 +164,7 @@ Draw each level of the `hue` variable at different locations on the major catego
![http://seaborn.pydata.org/_images/seaborn-stripplot-8.png](img/877dac04cc4c90a1e6b62a3f4c75cb92.jpg)
Control strip order by passing an explicit order:
通过传递显式顺序来控制条带顺序:
```py
>>> ax = sns.stripplot(x="time", y="tip", data=tips,
......@@ -174,7 +174,7 @@ Control strip order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-stripplot-9.png](img/582830f6213892477ca7f7fd8aea05e3.jpg)
Draw strips with large points and different aesthetics:
绘制具有大点和不同美感的条带:
```py
>>> ax = sns.stripplot("day", "total_bill", "smoker", data=tips,
......@@ -185,7 +185,7 @@ Draw strips with large points and different aesthetics:
![http://seaborn.pydata.org/_images/seaborn-stripplot-10.png](img/8d98047d8f8f2021d6ee3b3a679f0890.jpg)
Draw strips of observations on top of a box plot:
在箱形图上绘制观察条带:
```py
>>> ax = sns.boxplot(x="tip", y="day", data=tips, whis=np.inf)
......@@ -196,8 +196,7 @@ Draw strips of observations on top of a box plot:
![http://seaborn.pydata.org/_images/seaborn-stripplot-11.png](img/4affd3f4e9c07c5d6803b935d775b36f.jpg)
Draw strips of observations on top of a violin plot:
在小提琴情节的顶部绘制观察条带:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", data=tips,
... inner=None, color=".8")
......@@ -207,7 +206,7 @@ Draw strips of observations on top of a violin plot:
![http://seaborn.pydata.org/_images/seaborn-stripplot-12.png](img/a68cecbc7d2dbcff50e7244cafe440ec.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`stripplot()`](#seaborn.stripplot "seaborn.stripplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 组合[`stripplot()`](#seaborn.stripplot "seaborn.stripplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")。这允许在其他分类变量中进行分组。使用[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")比直接使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")更安全,因为它确保了跨方面的变量顺序的同步
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......@@ -218,4 +217,4 @@ Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to com
```
![http://seaborn.pydata.org/_images/seaborn-stripplot-13.png](img/1b02f55ed166cfeb0628691d84bc1958.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-stripplot-13.png](img/1b02f55ed166cfeb0628691d84bc1958.jpg)
......@@ -4,87 +4,84 @@
seaborn.swarmplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)
```
Draw a categorical scatterplot with non-overlapping points.
绘制具有非重叠点的分类散点图。
This function is similar to [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot"), but the points are adjusted (only along the categorical axis) so that they don’t overlap. This gives a better representation of the distribution of values, but it does not scale well to large numbers of observations. This style of plot is sometimes called a “beeswarm”.
此功能类似于 [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot"),,但调整点(仅沿分类轴),以便它们不重叠。 这样可以更好地表示值的分布,但不能很好地扩展到大量观察值。这种情节有时被称为“诅咒”
A swarm plot can be drawn on its own, but it is also a good complement to a box or violin plot in cases where you want to show all observations along with some representation of the underlying distribution.
一个群体图可以单独绘制,但如果你想要显示所有观察结果以及底层分布的一些表示,它也是一个盒子或小提琴图的良好补充。
Arranging the points properly requires an accurate transformation between data and point coordinates. This means that non-default axis limits must be set _before_ drawing the plot.
正确排列点需要在数据和点坐标之间进行精确转换。这意味着必须在绘制绘图之前设置非默认轴限制。
Input data can be passed in a variety of formats, including:
输入数据可以以多种格式传递,包括:
* 表示为列表,numpy arrays或pandas Series objects直接传递给`x``y`和/或`hue`参数。
* “长格式” DataFrame, `x``y``hue`变量将决定数据的绘制方式
* “宽格式”DataFrame,用于绘制每个数字列。
* 一个数组或向量列表。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
在大多数情况下,可以使用numpy或Python对象,但最好使用pandas对象,因为关联的名称将用于注释轴。此外,您可以使用分类类型来分组变量来控制绘图元素的顺序。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据具有数字或日期类型也是如此
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
有关更多信息,请参阅[教程](../tutorial/categorical.html#categorical-tutorial)
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
参数:`x, y, hue``数据`或矢量数据中的变量名称,可选
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
> 用于绘制长格式数据的输入。查看解释示例。
> Inputs for plotting long-form data. See examples for interpretation.
`data`:DataFrame, array, or 或数组列表, 可选
**data** : DataFrame, array, or list of arrays, optional
> 用于绘图的数据集。 如果 `x` 和 `y` 是不存在的, 会被解释成 wide-form. 否则会被解释成 long-form.
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
`order, hue_order`:字符串列表,可选
**order, hue_order** : lists of strings, optional
> 命令绘制分类级别,否则从数据对象推断级别。
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
`dodge`:布尔,可选
**dodge** : bool, optional
> 使用`hue`嵌套时,将其设置为`True`将沿着分类轴分离不同色调级别的条带。 否则,每个级别的点将绘制在一个群中。
> When using `hue` nesting, setting this to `True` will separate the strips for different hue levels along the categorical axis. Otherwise, the points for each level will be plotted in one swarm.
`orient`:“v” &#124; “h”, 可选
**orient** : “v” &#124; “h”, optional
> 图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但可用于指定“分类”变量何时是数字或何时绘制宽格式数据。
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
`color`:matplotlib color, 可选
**color** : matplotlib color, optional
> 所有元素的颜色,或渐变调色板的种子。
> Color for all of the elements, or seed for a gradient palette.
`palette`:调色板名称, list, or dict, 可选
**palette** : palette name, list, or dict, optional
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"),可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
`size`:float, 可选
**size** : float, optional
> 标记的直径,以点为单位。 (尽管`plt.scatter`用于绘制点,但此处的`size`参数采用“普通”标记大小而不是大小^ 2,如`plt.scatter`。
> Diameter of the markers, in points. (Although `plt.scatter` is used to draw the points, the `size` argument here takes a “normal” markersize and not size^2 like `plt.scatter`.
`edgecolor`:matplotlib color, “灰色”是特殊的,可选
**edgecolor** : matplotlib color, “gray” is special-cased, optional
> 每个点周围线条的颜色。如果传递`"gray"`,则亮度由用于点体的调色板决定。
> Color of the lines around each point. If you pass `"gray"`, the brightness is determined by the color palette used for the body of the points.
`linewidth`:float, 可选
**linewidth** : float, optional
> 构图元素的灰线宽度。
> Width of the gray lines that frame the plot elements.
`ax`:matplotlib Axes, 可选
**ax** : matplotlib Axes, optional
> Axes对象将绘图绘制到,否则使用当前轴。
> Axes object to draw the plot onto, otherwise uses the current Axes.
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
> 返回Axes对象,并在其上绘制绘图。
|
| --- | --- |
See also
A traditional box-and-whisker plot with a similar API.A combination of boxplot and kernel density estimation.A scatterplot where one variable is categorical. Can be used in conjunction with other plots to show each observation.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
参看
Examples
带有类似API的传统盒须图。框图和核密度估计的组合。散点图,其中一个变量是分类的。可以与其他图一起使用以显示每个观察结果。使用类组合分类图:<cite>FacetGrid</cite>
Draw a single horizontal swarm plot:
绘制单个水平群图:
```py
>>> import seaborn as sns
......@@ -96,7 +93,7 @@ Draw a single horizontal swarm plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-1.png](img/900c725fafc0f5e475a98f52f4ed7d04.jpg)
Group the swarms by a categorical variable:
通过分类变量对群组进行分组:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", data=tips)
......@@ -105,7 +102,7 @@ Group the swarms by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-2.png](img/414037bdbfc9b79cf5f12a30645f7301.jpg)
Draw horizontal swarms:
绘制水平群:
```py
>>> ax = sns.swarmplot(x="total_bill", y="day", data=tips)
......@@ -114,7 +111,7 @@ Draw horizontal swarms:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-3.png](img/b03c6dbcd2d2f71c2e5eafa99b46d96b.jpg)
Color the points using a second categorical variable:
使用第二个分类变量为点着色:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", hue="sex", data=tips)
......@@ -123,7 +120,7 @@ Color the points using a second categorical variable:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-4.png](img/12d5e5950bf28b7027b28766bc41989f.jpg)
Split each level of the `hue` variable along the categorical axis:
沿着分类轴拆分 `hue` 变量的每个级别:
```py
>>> ax = sns.swarmplot(x="day", y="total_bill", hue="smoker",
......@@ -133,7 +130,7 @@ Split each level of the `hue` variable along the categorical axis:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-5.png](img/6f9585fcbe42e72521292b80b0fdc97a.jpg)
Control swarm order by passing an explicit order:
通过传递显式顺序来控制swarm顺序:
```py
>>> ax = sns.swarmplot(x="time", y="tip", data=tips,
......@@ -143,7 +140,7 @@ Control swarm order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-6.png](img/73bbf8c6208a6e1c0dda89091dd509a4.jpg)
Plot using larger points:
绘制使用更大的点
```py
>>> ax = sns.swarmplot(x="time", y="tip", data=tips, size=6)
......@@ -152,7 +149,7 @@ Plot using larger points:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-7.png](img/34aa97c61dd6f6176fa2256880526439.jpg)
Draw swarms of observations on top of a box plot:
在箱形图上绘制大量观察结果:
```py
>>> ax = sns.boxplot(x="tip", y="day", data=tips, whis=np.inf)
......@@ -162,7 +159,7 @@ Draw swarms of observations on top of a box plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-8.png](img/d992e6312a3ed98025ad0913dbc46228.jpg)
Draw swarms of observations on top of a violin plot:
在小提琴图的顶部画出大量的观察结果:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", data=tips, inner=None)
......@@ -173,7 +170,7 @@ Draw swarms of observations on top of a violin plot:
![http://seaborn.pydata.org/_images/seaborn-swarmplot-9.png](img/735aa7eaadb9afb7a47a2d079b28a10b.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`swarmplot()`](#seaborn.swarmplot "seaborn.swarmplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
使用[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 去组合 [`swarmplot()`](#seaborn.swarmplot "seaborn.swarmplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). 这允许在其他分类变量中进行分组。 使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更安全,因为它确保了跨 facet 的变量顺序的同步
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......@@ -183,4 +180,4 @@ Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to com
```
![http://seaborn.pydata.org/_images/seaborn-swarmplot-10.png](img/7c1bc4a2871b9e0dbe2c23ed05fcae1b.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-swarmplot-10.png](img/7c1bc4a2871b9e0dbe2c23ed05fcae1b.jpg)
# seaborn.boxplot
> 译者:[FindNorthStar](https://github.com/FindNorthStar)
```py
seaborn.boxplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, width=0.8, dodge=True, fliersize=5, linewidth=None, whis=1.5, notch=False, ax=None, **kwargs)
```
Draw a box plot to show distributions with respect to categories.
seaborn.boxplot 接口的作用是绘制箱形图以展现与类别相关的数据分布状况。
箱形图(或盒须图)以一种利于变量之间比较或不同分类变量层次之间比较的方式来展示定量数据的分布。图中矩形框显示数据集的上下四分位数,而矩形框中延伸出的线段(触须)则用于显示其余数据的分布位置,剩下超过上下四分位间距的数据点则被视为“异常值”。
输入数据可以通过多种格式传入,包括:
A box plot (or box-and-whisker plot) shows the distribution of quantitative data in a way that facilitates comparisons between variables or across levels of a categorical variable. The box shows the quartiles of the dataset while the whiskers extend to show the rest of the distribution, except for points that are determined to be “outliers” using a method that is a function of the inter-quartile range.
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
Input data can be passed in a variety of formats, including:
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
参数:`x, y, hue``数据`或向量数据中的变量名称,可选
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
> 用于绘制长格式数据的输入。查看样例以进一步理解。
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
`data`:DataFrame,数组,数组列表,可选
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘图的数据集。如果`x`和`y`都缺失,那么数据将被视为宽格式。否则数据被视为长格式。
**data** : DataFrame, array, or list of arrays, optional
`order, hue_order`:字符串列表,可选
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 控制分类变量(对应的条形图)的绘制顺序,若缺失则从数据中推断分类变量的顺序。
**order, hue_order** : lists of strings, optional
`orient`:“v” &#124; “h”,可选
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
**orient** : “v” &#124; “h”, optional
`color`:matplotlib颜色,可选
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 所有元素的颜色,或渐变调色板的种子颜色。
**color** : matplotlib color, optional
`palette`:调色板名称,列表或字典,可选
> Color for all of the elements, or seed for a gradient palette.
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
**palette** : palette name, list, or dict, optional
`saturation`:float,可选
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 控制用于绘制颜色的原始饱和度的比例。通常大幅填充在轻微不饱和的颜色下看起来更好,如果您希望绘图颜色与输入颜色规格完美匹配可将其设置为`1`。
**saturation** : float, optional
`width`:float,可选
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
> 不使用色调嵌套时完整元素的宽度,或主要分组变量一个级别的所有元素的宽度。
**width** : float, optional
`dodge`:bool,可选
> Width of a full element when not using hue nesting, or width of all the elements for one level of the major grouping variable.
> 使用色调嵌套时,元素是否应沿分类轴移动。
**dodge** : bool, optional
`fliersize`:float,可选
> When hue nesting is used, whether elements should be shifted along the categorical axis.
> 用于表示异常值观察的标记的大小。
**fliersize** : float, optional
`linewidth`:float,可选
> Size of the markers used to indicate outlier observations.
> 构图元素的灰线宽度。
**linewidth** : float, optional
`whis`:float,可选
> Width of the gray lines that frame the plot elements.
> 控制在超过高低四分位数时IQR的比例,因此需要延长绘制的触须线段。超出此范围的点将被识别为异常值。
**whis** : float, optional
`notch`:boolean,可选
> Proportion of the IQR past the low and high quartiles to extend the plot whiskers. Points outside this range will be identified as outliers.
> 是否使矩形框“凹陷”以指示中位数的置信区间。还有其他几个参数可以控制凹槽的绘制方式;参见 `plt.boxplot` 以查看关于此问题的更多帮助信息。
**notch** : boolean, optional
`ax`:matplotlib轴,可选
> Whether to “notch” the box to indicate a confidence interval for the median. There are several other parameters that can control how the notches are drawn; see the `plt.boxplot` help for more information on them.
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
**ax** : matplotlib Axes, optional
`kwargs`:键,值映射
> Axes object to draw the plot onto, otherwise uses the current Axes.
> 其他在绘图时传给 `plt.boxplot` 的参数。
**kwargs** : key, value mappings
> Other keyword arguments are passed through to `plt.boxplot` at draw time.
返回值:`ax`:matplotlib轴
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 返回Axes对轴象,并在其上绘制绘图。
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
亦可参见
A combination of boxplot and kernel density estimation.A scatterplot where one variable is categorical. Can be used in conjunction with other plots to show each observation.A categorical scatterplot where the points do not overlap. Can be used with other plots to show each observation.
boxplot和核密度估计的结合。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
Examples
示例
Draw a single horizontal boxplot:
绘制一个单独的横向箱型图:
```py
>>> import seaborn as sns
......@@ -108,7 +108,7 @@ Draw a single horizontal boxplot:
![http://seaborn.pydata.org/_images/seaborn-boxplot-1.png](img/a60c5e81f1e6cf2aeb7d9790851ca60d.jpg)
Draw a vertical boxplot grouped by a categorical variable:
根据分类变量分组绘制一个纵向的箱型图:
```py
>>> ax = sns.boxplot(x="day", y="total_bill", data=tips)
......@@ -117,7 +117,7 @@ Draw a vertical boxplot grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-boxplot-2.png](img/26d08ab02c44cb0a819065f27a1b7f84.jpg)
Draw a boxplot with nested grouping by two categorical variables:
根据2个分类变量嵌套分组绘制一个箱型图:
```py
>>> ax = sns.boxplot(x="day", y="total_bill", hue="smoker",
......@@ -127,7 +127,7 @@ Draw a boxplot with nested grouping by two categorical variables:
![http://seaborn.pydata.org/_images/seaborn-boxplot-3.png](img/d642aa20a439141528ed8a872a4822a4.jpg)
Draw a boxplot with nested grouping when some bins are empty:
当一些数据为空时根据嵌套分组绘制一个箱型图:
```py
>>> ax = sns.boxplot(x="day", y="total_bill", hue="time",
......@@ -137,7 +137,7 @@ Draw a boxplot with nested grouping when some bins are empty:
![http://seaborn.pydata.org/_images/seaborn-boxplot-4.png](img/97751f7296df86f26e8eb70275541082.jpg)
Control box order by passing an explicit order:
通过显式传入参数指定顺序控制箱型图的显示顺序:
```py
>>> ax = sns.boxplot(x="time", y="tip", data=tips,
......@@ -147,7 +147,7 @@ Control box order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-boxplot-5.png](img/8ac363c4f6fd1e8ef5a4dd62d236ce9d.jpg)
Draw a boxplot for each numeric variable in a DataFrame:
针对DataFrame里每一个数值型变量绘制箱型图:
```py
>>> iris = sns.load_dataset("iris")
......@@ -157,7 +157,7 @@ Draw a boxplot for each numeric variable in a DataFrame:
![http://seaborn.pydata.org/_images/seaborn-boxplot-6.png](img/7592f72da714721ad272271754ee8454.jpg)
Use `hue` without changing box position or width:
使用 `hue` 参数无需改变箱型图的位置或宽度:
```py
>>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
......@@ -168,7 +168,7 @@ Use `hue` without changing box position or width:
![http://seaborn.pydata.org/_images/seaborn-boxplot-7.png](img/583a43fccfad9c80a852b79bbd864c3b.jpg)
Use [`swarmplot()`](seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot") to show the datapoints on top of the boxes:
使用 [`swarmplot()`](seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot") 展示箱型图顶部的数据点:
```py
>>> ax = sns.boxplot(x="day", y="total_bill", data=tips)
......@@ -178,7 +178,7 @@ Use [`swarmplot()`](seaborn.swarmplot.html#seaborn.swarmplot "seaborn.swarmplot"
![http://seaborn.pydata.org/_images/seaborn-boxplot-8.png](img/627c14ca4d7cabe1d122fd0b9d2586bd.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`pointplot()`](seaborn.pointplot.html#seaborn.pointplot "seaborn.pointplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")[`pointplot()`](seaborn.pointplot.html#seaborn.pointplot "seaborn.pointplot") 以及 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 结合起来使用。这允许您通过额外的分类变量进行分组。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更为安全,因为它保证了不同切面上变量同步的顺序:
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......
# seaborn.violinplot
> 译者:[FindNorthStar](https://github.com/FindNorthStar)
```py
seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, bw='scott', cut=2, scale='area', scale_hue=True, gridsize=100, width=0.8, inner='box', split=False, dodge=True, orient=None, linewidth=None, color=None, palette=None, saturation=0.75, ax=None, **kwargs)
```
Draw a combination of boxplot and kernel density estimate.
结合箱型图与核密度估计绘图。
小提琴图的功能与箱型图类似。 它显示了一个(或多个)分类变量多个属性上的定量数据的分布,从而可以比较这些分布。与箱形图不同,其中所有绘图单元都与实际数据点对应,小提琴图描述了基础数据分布的核密度估计。
小提琴图可以是一种单次显示多个数据分布的有效且有吸引力的方式,但请记住,估计过程受样本大小的影响,相对较小样本的小提琴可能看起来非常平滑,这种平滑具有误导性。
A violin plot plays a similar role as a box and whisker plot. It shows the distribution of quantitative data across several levels of one (or more) categorical variables such that those distributions can be compared. Unlike a box plot, in which all of the plot components correspond to actual datapoints, the violin plot features a kernel density estimation of the underlying distribution.
输入数据可以通过多种格式传入,包括:
This can be an effective and attractive way to show multiple distributions of data at once, but keep in mind that the estimation procedure is influenced by the sample size, and violins for relatively small samples might look misleadingly smooth.
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
Input data can be passed in a variety of formats, including:
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
更多信息请参阅 [tutorial](../tutorial/categorical.html#categorical-tutorial)
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
参数:`x, y, hue``数据`或向量数据中的变量名称,可选
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
> 用于绘制长格式数据的输入。查看样例以进一步理解。
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
`data`:DataFrame,数组,数组列表,可选
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘图的数据集。如果`x`和`y`都缺失,那么数据将被视为宽格式。否则数据被视为长格式。
**data** : DataFrame, array, or list of arrays, optional
`order, hue_order`:字符串列表,可选
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 控制分类变量(对应的条形图)的绘制顺序,若缺失则从数据中推断分类变量的顺序。
**order, hue_order** : lists of strings, optional
`bw`:{‘scott’, ‘silverman’, float},可选
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 内置变量值或浮点数的比例因子都用来计算核密度的带宽。实际的核大小由比例因子乘以每个分箱内数据的标准差确定。
**bw** : {‘scott’, ‘silverman’, float}, optional
`cut`:float,可选
> Either the name of a reference rule or the scale factor to use when computing the kernel bandwidth. The actual kernel size will be determined by multiplying the scale factor by the standard deviation of the data within each bin.
> 以带宽大小为单位的距离,以控制小提琴图外壳延伸超过内部极端数据点的密度。设置为0以将小提琴图范围限制在观察数据的范围内。(例如,在 `ggplot` 中具有与 `trim=True` 相同的效果)
**cut** : float, optional
`scale`:{“area”, “count”, “width”},可选
> Distance, in units of bandwidth size, to extend the density past the extreme datapoints. Set to 0 to limit the violin range within the range of the observed data (i.e., to have the same effect as `trim=True` in `ggplot`.
> 该方法用于缩放每张小提琴图的宽度。若为 `area` ,每张小提琴图具有相同的面积。若为 `count` ,小提琴的宽度会根据分箱中观察点的数量进行缩放。若为 `width` ,每张小提琴图具有相同的宽度。
**scale** : {“area”, “count”, “width”}, optional
`scale_hue`:bool,可选
> The method used to scale the width of each violin. If `area`, each violin will have the same area. If `count`, the width of the violins will be scaled by the number of observations in that bin. If `width`, each violin will have the same width.
> 当使用色调参数 `hue` 变量绘制嵌套小提琴图时,该参数决定缩放比例是在主要分组变量(`scale_hue=True`)的每个级别内还是在图上的所有小提琴图(`scale_hue=False`)内计算出来的。
**scale_hue** : bool, optional
`gridsize`:int,可选
> When nesting violins using a `hue` variable, this parameter determines whether the scaling is computed within each level of the major grouping variable (`scale_hue=True`) or across all the violins on the plot (`scale_hue=False`).
> 用于计算核密度估计的离散网格中的数据点数目。
**gridsize** : int, optional
`width`:float,可选
> Number of points in the discrete grid used to compute the kernel density estimate.
> 不使用色调嵌套时的完整元素的宽度,或主要分组变量的一个级别的所有元素的宽度。
**width** : float, optional
`inner`:{“box”, “quartile”, “point”, “stick”, None},可选
> Width of a full element when not using hue nesting, or width of all the elements for one level of the major grouping variable.
> 控制小提琴图内部数据点的表示。若为`box`,则绘制一个微型箱型图。若为`quartiles`,则显示四分位数线。若为`point`或`stick`,则显示具体数据点或数据线。使用`None`则绘制不加修饰的小提琴图。
**inner** : {“box”, “quartile”, “point”, “stick”, None}, optional
`split`:bool,可选
> Representation of the datapoints in the violin interior. If `box`, draw a miniature boxplot. If `quartiles`, draw the quartiles of the distribution. If `point` or `stick`, show each underlying datapoint. Using `None` will draw unadorned violins.
> 当使用带有两种颜色的变量时,将`split`设置为True则会为每种颜色绘制对应半边小提琴。从而可以更容易直接的比较分布。
**split** : bool, optional
`dodge`:bool,可选
> When using hue nesting with a variable that takes two levels, setting `split` to True will draw half of a violin for each level. This can make it easier to directly compare the distributions.
> 使用色调嵌套时,元素是否应沿分类轴移动。
**dodge** : bool, optional
`orient`:“v” &#124; “h”,可选
> When hue nesting is used, whether elements should be shifted along the categorical axis.
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
**orient** : “v” &#124; “h”, optional
`linewidth`:float,可选
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 构图元素的灰线宽度。
**linewidth** : float, optional
`color`:matplotlib颜色,可选
> Width of the gray lines that frame the plot elements.
> 所有元素的颜色,或渐变调色板的种子颜色。
**color** : matplotlib color, optional
`palette`:调色板名称,列表或字典,可选
> Color for all of the elements, or seed for a gradient palette.
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
**palette** : palette name, list, or dict, optional
`saturation`:float,可选
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 控制用于绘制颜色的原始饱和度的比例。通常大幅填充在轻微不饱和的颜色下看起来更好,如果您希望绘图颜色与输入颜色规格完美匹配可将其设置为`1`。
**saturation** : float, optional
`ax`:matplotlib轴,可选
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
**ax** : matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
返回值:`ax`:matplotlib轴
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 返回Axes对轴象,并在其上绘制绘图。
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
亦可参见
A traditional box-and-whisker plot with a similar API.A scatterplot where one variable is categorical. Can be used in conjunction with other plots to show each observation.A categorical scatterplot where the points do not overlap. Can be used with other plots to show each observation.
一个传统的箱型图具有类似的API。当一个变量是分类变量的散点图。可以与其他图表结合使用以展示各自的观测结果。分类散点图的特点是其中数据点互不重叠。可以与其他图表结合使用以展示各自的观测结果。
Examples
示例
Draw a single horizontal violinplot:
绘制一个单独的横向小提琴图:
```py
>>> import seaborn as sns
......@@ -122,7 +122,7 @@ Draw a single horizontal violinplot:
![http://seaborn.pydata.org/_images/seaborn-violinplot-1.png](img/997c424ce3337d1c47dea839b9dbdcae.jpg)
Draw a vertical violinplot grouped by a categorical variable:
根据分类变量分组绘制一个纵向的小提琴图:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", data=tips)
......@@ -131,7 +131,7 @@ Draw a vertical violinplot grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-violinplot-2.png](img/35c303fe21899eb631a454ab2d09e1bf.jpg)
Draw a violinplot with nested grouping by two categorical variables:
根据2个分类变量嵌套分组绘制一个小提琴图:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
......@@ -141,7 +141,7 @@ Draw a violinplot with nested grouping by two categorical variables:
![http://seaborn.pydata.org/_images/seaborn-violinplot-3.png](img/518916184779b02556d17a4d7366ba4f.jpg)
Draw split violins to compare the across the hue variable:
绘制分割的小提琴图以比较不同的色调变量:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
......@@ -151,7 +151,7 @@ Draw split violins to compare the across the hue variable:
![http://seaborn.pydata.org/_images/seaborn-violinplot-4.png](img/556be3cec3d1462768f0cc39618394ee.jpg)
Control violin order by passing an explicit order:
通过显式传入参数指定顺序控制小提琴图的显示顺序:
```py
>>> ax = sns.violinplot(x="time", y="tip", data=tips,
......@@ -161,7 +161,7 @@ Control violin order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-violinplot-5.png](img/0a27825dabd4d46b78291be90e8f255e.jpg)
Scale the violin width by the number of observations in each bin:
将小提琴宽度缩放为每个分箱中观察到的数据点数目:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="sex",
......@@ -172,7 +172,7 @@ Scale the violin width by the number of observations in each bin:
![http://seaborn.pydata.org/_images/seaborn-violinplot-6.png](img/827ec31007a6e721317dd1ef46a8602f.jpg)
Draw the quartiles as horizontal lines instead of a mini-box:
将四分位数绘制为水平线而不是迷你箱型图:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="sex",
......@@ -183,7 +183,7 @@ Draw the quartiles as horizontal lines instead of a mini-box:
![http://seaborn.pydata.org/_images/seaborn-violinplot-7.png](img/09cb7121a5be805931cc8ae1c99d3cf9.jpg)
Show each observation with a stick inside the violin:
用小提琴图内部的横线显示每个观察到的数据点:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="sex",
......@@ -194,7 +194,7 @@ Show each observation with a stick inside the violin:
![http://seaborn.pydata.org/_images/seaborn-violinplot-8.png](img/5c7220bdfc81c3823862c2988af57776.jpg)
Scale the density relative to the counts across all bins:
根据所有分箱的数据点数目对密度进行缩放:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="sex",
......@@ -205,7 +205,7 @@ Scale the density relative to the counts across all bins:
![http://seaborn.pydata.org/_images/seaborn-violinplot-9.png](img/b8b693d813ee5778cb52a3f3f634fc11.jpg)
Use a narrow bandwidth to reduce the amount of smoothing:
使用窄带宽来减少平滑量:
```py
>>> ax = sns.violinplot(x="day", y="total_bill", hue="sex",
......@@ -217,7 +217,7 @@ Use a narrow bandwidth to reduce the amount of smoothing:
![http://seaborn.pydata.org/_images/seaborn-violinplot-10.png](img/a8ea9b9779973bf3274cc3f154bb6029.jpg)
Draw horizontal violins:
绘制横向小提琴图:
```py
>>> planets = sns.load_dataset("planets")
......@@ -229,7 +229,7 @@ Draw horizontal violins:
![http://seaborn.pydata.org/_images/seaborn-violinplot-11.png](img/7a72774eb92deca2a76e6428021a5bd6.jpg)
Don’t let density extend past extreme values in the data:
不要让密度超出数据中的极端数值:
```py
>>> ax = sns.violinplot(x="orbital_period", y="method",
......@@ -240,7 +240,7 @@ Don’t let density extend past extreme values in the data:
![http://seaborn.pydata.org/_images/seaborn-violinplot-12.png](img/eb118f7308dc5e81aa3ed5b5524a1182.jpg)
Use `hue` without changing violin position or width:
使用 `hue` 而不改变小提琴图的位置或宽度:
```py
>>> tips["weekend"] = tips["day"].isin(["Sat", "Sun"])
......@@ -251,7 +251,7 @@ Use `hue` without changing violin position or width:
![http://seaborn.pydata.org/_images/seaborn-violinplot-13.png](img/fad2cab7c30663b1f48e1015ad10f310.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`violinplot()`](#seaborn.violinplot "seaborn.violinplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")[`violinplot()`](#seaborn.violinplot "seaborn.violinplot") 以及 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 结合起来使用。这允许您通过额外的分类变量进行分组。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更为安全,因为它保证了不同切面上变量同步的顺序:
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......
# seaborn.boxenplot
> 译者:[FindNorthStar](https://github.com/FindNorthStar)
```py
seaborn.boxenplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, width=0.8, dodge=True, k_depth='proportion', linewidth=None, scale='exponential', outlier_prop=None, ax=None, **kwargs)
```
Draw an enhanced box plot for larger datasets.
为更大的数据集绘制增强的箱型图。
This style of plot was originally named a “letter value” plot because it shows a large number of quantiles that are defined as “letter values”. It is similar to a box plot in plotting a nonparametric representation of a distribution in which all features correspond to actual observations. By plotting more quantiles, it provides more information about the shape of the distribution, particularly in the tails. 您可以阅读介绍这个图表的论文来获得更详细解释:
这种风格的绘图最初被命名为“信值图”,因为它显示了大量被定义为“置信区间”的分位数。它类似于绘制分布的非参数表示的箱形图,其中所有特征对应于实际观察的数值点。通过绘制更多分位数,它提供了有关分布形状的更多信息,特别是尾部数据的分布。欲了解更详细的解释,您可以阅读介绍该绘图的论文:
[https://vita.had.co.nz/papers/letter-value-plot.html](https://vita.had.co.nz/papers/letter-value-plot.html)
Input data can be passed in a variety of formats, including:
输入数据可以通过多种格式传入,包括:
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
参数:`x, y, hue``data`或向量数据中的变量名称,可选
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
> 用于绘制长格式数据的输入。查看样例以进一步理解。
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
`data`:DataFrame,数组,数组列表,可选
> Inputs for plotting long-form data. See examples for interpretation.
> 用于绘图的数据集。如果`x`和`y`都缺失,那么数据将被视为宽格式。否则数据被视为长格式。
**data** : DataFrame, array, or list of arrays, optional
`order, hue_order`:字符串列表,可选
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 控制分类变量(对应的条形图)的绘制顺序,若缺失则从数据中推断分类变量的顺序。
**order, hue_order** : lists of strings, optional
`orient`:“v” &#124; “h”,可选
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
**orient** : “v” &#124; “h”, optional
`color`:matplotlib颜色,可选
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 所有元素的颜色,或渐变调色板的种子颜色。
**color** : matplotlib color, optional
`palette`:调色板名称,列表或字典,可选
> Color for all of the elements, or seed for a gradient palette.
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
**palette** : palette name, list, or dict, optional
`saturation`:float,可选
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 控制用于绘制颜色的原始饱和度的比例。通常大幅填充在轻微不饱和的颜色下看起来更好,如果您希望绘图颜色与输入颜色规格完美匹配可将其设置为`1`。
**saturation** : float, optional
`width`:float,可选
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
> 不使用色调嵌套时完整元素的宽度,或主要分组变量一个级别的所有元素的宽度。
**width** : float, optional
`dodge`:bool,可选
> Width of a full element when not using hue nesting, or width of all the elements for one level of the major grouping variable.
> 使用色调嵌套时,元素是否应沿分类轴移动。
**dodge** : bool, optional
`k_depth`:“proportion” &#124; “tukey” &#124; “trustworthy”,可选
> When hue nesting is used, whether elements should be shifted along the categorical axis.
> 通过增大百分比的粒度控制绘制的盒形图数目。所有方法都在Wickham的论文中有详细描述。每个参数代表利用不同的统计特性对异常值的数量做出不同的假设。
**k_depth** : “proportion” &#124; “tukey” &#124; “trustworthy”, optional
`linewidth`:float,可选
> The number of boxes, and by extension number of percentiles, to draw. All methods are detailed in Wickham’s paper. Each makes different assumptions about the number of outliers and leverages different statistical properties.
> 构图元素的灰线宽度。
**linewidth** : float, optional
`scale`:“linear” &#124; “exponential” &#124; “area”
> Width of the gray lines that frame the plot elements.
> 用于控制增强箱型图宽度的方法。所有参数都会给显示效果造成影响。 “linear” 通过恒定的线性因子减小宽度,“exponential” 使用未覆盖的数据的比例调整宽度, “area” 与所覆盖的数据的百分比成比例。
**scale** : “linear” &#124; “exponential” &#124; “area”
`outlier_prop`:float,可选
> Method to use for the width of the letter value boxes. All give similar results visually. “linear” reduces the width by a constant linear factor, “exponential” uses the proportion of data not covered, “area” is proportional to the percentage of data covered.
> 被认为是异常值的数据比例。与 `k_depth` 结合使用以确定要绘制的百分位数。默认值为0.007作为异常值的比例。该参数取值应在[0,1]范围内。
**outlier_prop** : float, optional
`ax`:matplotlib轴,可选
> Proportion of data believed to be outliers. Used in conjunction with k_depth to determine the number of percentiles to draw. Defaults to 0.007 as a proportion of outliers. Should be in range [0, 1].
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
**ax** : matplotlib Axes, optional
`kwargs`:键,值映射
> Axes object to draw the plot onto, otherwise uses the current Axes.
> 其他在绘制时传递给`plt.plot`和`plt.scatter`参数。
**kwargs** : key, value mappings
> Other keyword arguments are passed through to `plt.plot` and `plt.scatter` at draw time.
返回值:`ax`:matplotlib轴
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 返回Axes对轴象,并在其上绘制绘图。
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
亦可参见
A combination of boxplot and kernel density estimation.A traditional box-and-whisker plot with a similar API.
boxplot和核密度估计的结合。一个传统的箱型图具有类似的API。
Examples
示例
Draw a single horizontal boxen plot:
绘制一个独立的横向增强箱型图:
```py
>>> import seaborn as sns
......@@ -110,7 +110,7 @@ Draw a single horizontal boxen plot:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-1.png](img/ea7362d005109093ddfe7d7a0039a13e.jpg)
Draw a vertical boxen plot grouped by a categorical variable:
根据分类变量分组绘制一个纵向的增强箱型图:
```py
>>> ax = sns.boxenplot(x="day", y="total_bill", data=tips)
......@@ -119,7 +119,7 @@ Draw a vertical boxen plot grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-2.png](img/31c79f0cf22d453e10799da960e3e801.jpg)
Draw a letter value plot with nested grouping by two categorical variables:
根据2个分类变量嵌套分组绘制一个增强箱型图:
```py
>>> ax = sns.boxenplot(x="day", y="total_bill", hue="smoker",
......@@ -129,7 +129,7 @@ Draw a letter value plot with nested grouping by two categorical variables:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-3.png](img/1db91ed8446afc825fa5bba21f1ef278.jpg)
Draw a boxen plot with nested grouping when some bins are empty:
当一些数据为空时根据嵌套分组绘制一个增强箱型图:
```py
>>> ax = sns.boxenplot(x="day", y="total_bill", hue="time",
......@@ -139,7 +139,7 @@ Draw a boxen plot with nested grouping when some bins are empty:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-4.png](img/2e57af8b26439c244046ff7846601335.jpg)
Control box order by passing an explicit order:
通过显式传入参数指定顺序控制箱型图的显示顺序:
```py
>>> ax = sns.boxenplot(x="time", y="tip", data=tips,
......@@ -149,7 +149,7 @@ Control box order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-5.png](img/e8fa81696195ce058546e429317075bc.jpg)
Draw a boxen plot for each numeric variable in a DataFrame:
针对DataFrame里每一个数值型变量绘制增强箱型图:
```py
>>> iris = sns.load_dataset("iris")
......@@ -159,7 +159,7 @@ Draw a boxen plot for each numeric variable in a DataFrame:
![http://seaborn.pydata.org/_images/seaborn-boxenplot-6.png](img/a9e939280daed8ec0712c8e6e6be78fb.jpg)
Use [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot") to show the datapoints on top of the boxes:
使用 [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot") 显示箱型图顶部的数据点:
```py
>>> ax = sns.boxenplot(x="day", y="total_bill", data=tips)
......@@ -170,7 +170,7 @@ Use [`stripplot()`](seaborn.stripplot.html#seaborn.stripplot "seaborn.stripplot"
![http://seaborn.pydata.org/_images/seaborn-boxenplot-7.png](img/fb3de8051b91bb0be2143717f96c0a7c.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine [`boxenplot()`](#seaborn.boxenplot "seaborn.boxenplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine [`boxenplot()`](#seaborn.boxenplot "seaborn.boxenplot") 以及 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 结合起来使用。这允许您通过额外的分类变量进行分组。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更为安全,因为它保证了不同切面上变量同步的顺序:
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......
# seaborn.pointplot
> 译者:[FindNorthStar](https://github.com/FindNorthStar)
```py
seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, estimator=<function mean>, ci=95, n_boot=1000, units=None, markers='o', linestyles='-', dodge=False, join=True, scale=1, orient=None, color=None, palette=None, errwidth=None, capsize=None, ax=None, **kwargs)
```
Show point estimates and confidence intervals using scatter plot glyphs.
通过绘制散点连线显示数据点的估计值和置信区间。
点图代表散点图位置的数值变量的中心趋势估计,并使用误差线提供关于该估计的不确定性的一些指示。
点图比条形图在聚焦一个或多个分类变量的不同级别之间的比较时更为有用。点图尤其善于表现交互作用:一个分类变量的层次之间的关系如何在第二个分类变量的层次之间变化。连接来自相同 `色调` 等级的每个点的线允许交互作用通过斜率的差异进行判断,这使得更容易对几组数据点或数据线的高度进行比较。
A point plot represents an estimate of central tendency for a numeric variable by the position of scatter plot points and provides some indication of the uncertainty around that estimate using error bars.
重要的一点是点图仅显示平均值(或其他估计值),但在许多情况下,显示分类变量的每个级别的值的分布可能会带有更多信息。在这种情况下,其他绘图方法,例如箱型图或小提琴图可能更合适。
Point plots can be more useful than bar plots for focusing comparisons between different levels of one or more categorical variables. They are particularly adept at showing interactions: how the relationship between levels of one categorical variable changes across levels of a second categorical variable. The lines that join each point from the same `hue` level allow interactions to be judged by differences in slope, which is easier for the eyes than comparing the heights of several groups of points or bars.
输入数据可以通过多种格式传入,包括:
It is important to keep in mind that a point plot shows only the mean (or other estimator) value, but in many cases it may be more informative to show the distribution of values at each level of the categorical variables. In that case, other approaches such as a box or violin plot may be more appropriate.
* 格式为列表,numpy数组或pandas Series对象的数据向量可以直接传递给`x``y``hue`参数。
* 对于长格式的DataFrame,`x``y`,和`hue`参数会决定如何绘制数据。
* 对于宽格式的DataFrame,每一列数值列都会被绘制。
* 一个数组或向量的列表。
Input data can be passed in a variety of formats, including:
在大多数情况下,可以使用numpy或Python对象,但更推荐使用pandas对象,因为与数据关联的列名/行名可以用于标注横轴/纵轴的名称。此外,您可以使用分类类型对变量进行分组以控制绘图元素的顺序。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
此函数始终将其中一个变量视为分类,并在相关轴上的序数位置(0,1,... n)处绘制数据,即使数据属于数值类型或日期类型也是如此。
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
更多信息请参阅 [教程](../tutorial/categorical.html#categorical-tutorial)
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
参数:`x, y, hue``data`或向量数据中的变量名称,可选
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
> 用于绘制长格式数据的输入。查看样例以进一步理解。
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
`data`:DataFrame,数组,数组列表,可选
> Inputs for plotting long-form data. See examples for interpretation.
> 于绘图的数据集。如果`x`和`y`都缺失,那么数据将被视为宽格式。否则数据被视为长格式。
**data** : DataFrame, array, or list of arrays, optional
`order, hue_order`:字符串列表,可选
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
**order, hue_order** : lists of strings, optional
`estimator`:调用函数实现向量 -&gt; 标量的映射,可选
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 在每个分箱内进行估计的统计函数。
**estimator** : callable that maps vector -&gt; scalar, optional
`ci`:float 或 “sd” 或 None,可选
> Statistical function to estimate within each categorical bin.
> 在估计值附近绘制置信区间的尺寸大小。如果是“sd”,则跳过引导阶段并绘制观察数据点的标准差。如果为 `None`,则不会执行引导过程,并且不会绘制误差块。
**ci** : float or “sd” or None, optional
`n_boot`:int,可选
> Size of confidence intervals to draw around estimated values. If “sd”, skip bootstrapping and draw the standard deviation of the observations. If `None`, no bootstrapping will be performed, and error bars will not be drawn.
> 计算置信区间时使用的引导迭代次数。
**n_boot** : int, optional
`units``data` 或vector data中变量的名称,可选
> Number of bootstrap iterations to use when computing confidence intervals.
> 采样单元的标识符,用于执行多级引导过程(计算置信区间等)并能够处理重复测量的设定。
**units** : name of variable in `data` or vector data, optional
`markers`:字符串或字符串列表,可选
> Identifier of sampling units, which will be used to perform a multilevel bootstrap and account for repeated measures design.
> 用于每个`hue`色调的级别的标记。
**markers** : string or list of strings, optional
`linestyles`:字符串或字符串列表,可选
> Markers to use for each of the `hue` levels.
> 用于每个`hue`色调的级别的线条风格。
**linestyles** : string or list of strings, optional
`dodge`:bool或float,可选
> Line styles to use for each of the `hue` levels.
> 用于沿着分类轴分离`hue`变量的每个级别数据点的数量。
**dodge** : bool or float, optional
`join`:bool,可选
> Amount to separate the points for each level of the `hue` variable along the categorical axis.
> 如果为`True`,则在`hue`级别相同的点估计值之间绘制线条。
**join** : bool, optional
`scale`:float,可选
> If `True`, lines will be drawn between point estimates at the same `hue` level.
> 绘图元素的比例因子。
**scale** : float, optional
`orient`:“v” &#124; “h”,可选
> Scale factor for the plot elements.
> 控制绘图的方向(垂直或水平)。这通常是从输入变量的dtype推断出来的,但是当“分类”变量为数值型或绘制宽格式数据时可用于指定绘图的方向。
**orient** : “v” &#124; “h”, optional
`color`:matplotlib颜色,可选
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
> 所有元素的颜色,或渐变调色板的种子颜色。
**color** : matplotlib color, optional
`palette`:调色板名称,列表或字典,可选
> Color for all of the elements, or seed for a gradient palette.
> 用于`hue`变量的不同级别的颜色。可以从 [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette") 得到一些解释,或者将色调级别映射到matplotlib颜色的字典。
**palette** : palette name, list, or dict, optional
`errwidth`:float,可选
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
> 误差线(和上下限指示线)的厚度。
**errwidth** : float, optional
`capsize`:float,可选
> Thickness of error bar lines (and caps).
> 误差线“上下限指示线”的宽度。
**capsize** : float, optional
`ax`:matplotlib轴,可选
> Width of the “caps” on error bars.
> 绘图时使用的Axes轴对象,否则使用当前Axes轴对象。
**ax** : matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
返回值:`ax`:matplotlib轴
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 返回Axes对轴象,并在其上绘制绘图。
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
See also
亦可参见
Show point estimates and confidence intervals using bars.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
使用线条显示数据点的估计值和置信区间。将分类类别的绘图与该类结合使用:<cite>FacetGrid</cite>
Examples
示例
Draw a set of vertical point plots grouped by a categorical variable:
绘制一组按分类变量分组的纵向点图:
```py
>>> import seaborn as sns
......@@ -124,7 +124,7 @@ Draw a set of vertical point plots grouped by a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-pointplot-1.png](img/f5eb9519edb052868537ca9735f0f8df.jpg)
Draw a set of vertical points with nested grouping by a two variables:
通过两个嵌套分组的变量绘制一组纵向的点图:
```py
>>> ax = sns.pointplot(x="time", y="total_bill", hue="smoker",
......@@ -134,7 +134,7 @@ Draw a set of vertical points with nested grouping by a two variables:
![http://seaborn.pydata.org/_images/seaborn-pointplot-2.png](img/864eda3b3c2fcc6b0bdb53c84c3dafcf.jpg)
Separate the points for different hue levels along the categorical axis:
沿着分类轴分离不同色调级别的点:
```py
>>> ax = sns.pointplot(x="time", y="total_bill", hue="smoker",
......@@ -144,7 +144,7 @@ Separate the points for different hue levels along the categorical axis:
![http://seaborn.pydata.org/_images/seaborn-pointplot-3.png](img/b7f6772294dcf0d9b7035314c114c54b.jpg)
Use a different marker and line style for the hue levels:
根据色调级别使用不同的标记和线条样式:
```py
>>> ax = sns.pointplot(x="time", y="total_bill", hue="smoker",
......@@ -156,7 +156,7 @@ Use a different marker and line style for the hue levels:
![http://seaborn.pydata.org/_images/seaborn-pointplot-4.png](img/a97ae4389fc8bc946eb62e06c173b3e3.jpg)
Draw a set of horizontal points:
绘制一组横向的点图:
```py
>>> ax = sns.pointplot(x="tip", y="day", data=tips)
......@@ -165,7 +165,7 @@ Draw a set of horizontal points:
![http://seaborn.pydata.org/_images/seaborn-pointplot-5.png](img/4217fbfe6aaba42c4d18a69c5b8c9fc4.jpg)
Don’t draw a line connecting each point:
不要绘制每个点的连接线:
```py
>>> ax = sns.pointplot(x="tip", y="day", data=tips, join=False)
......@@ -174,7 +174,7 @@ Don’t draw a line connecting each point:
![http://seaborn.pydata.org/_images/seaborn-pointplot-6.png](img/96a33f32e85dcced62c9fc4ff063fe3d.jpg)
Use a different color for a single-layer plot:
对单层图使用不同的颜色:
```py
>>> ax = sns.pointplot("time", y="total_bill", data=tips,
......@@ -184,7 +184,7 @@ Use a different color for a single-layer plot:
![http://seaborn.pydata.org/_images/seaborn-pointplot-7.png](img/1e3348f06e5cd7876d5bc530b04d3d93.jpg)
Use a different color palette for the points:
为数据点使用不同的调色板:
```py
>>> ax = sns.pointplot(x="time", y="total_bill", hue="smoker",
......@@ -194,7 +194,7 @@ Use a different color palette for the points:
![http://seaborn.pydata.org/_images/seaborn-pointplot-8.png](img/d4a4eeea79c55b0ae9d3088746b6503a.jpg)
Control point order by passing an explicit order:
通过显式传入参数指定顺序控制点的显示顺序:
```py
>>> ax = sns.pointplot(x="time", y="tip", data=tips,
......@@ -204,7 +204,7 @@ Control point order by passing an explicit order:
![http://seaborn.pydata.org/_images/seaborn-pointplot-9.png](img/4c08e24283b6829b3d91e3c23de56923.jpg)
Use median as the estimate of central tendency:
用中位数作为集中趋势的估计:
```py
>>> from numpy import median
......@@ -214,7 +214,7 @@ Use median as the estimate of central tendency:
![http://seaborn.pydata.org/_images/seaborn-pointplot-10.png](img/0ec9398faa407996527db66db46c71f2.jpg)
Show the standard error of the mean with the error bars:
用误差线显示均值的标准误差:
```py
>>> ax = sns.pointplot(x="day", y="tip", data=tips, ci=68)
......@@ -223,7 +223,7 @@ Show the standard error of the mean with the error bars:
![http://seaborn.pydata.org/_images/seaborn-pointplot-11.png](img/f9f6dd93a512624527b38dcc26d97e37.jpg)
Show standard deviation of observations instead of a confidence interval:
显示观测值的标准偏差而不是置信区间:
```py
>>> ax = sns.pointplot(x="day", y="tip", data=tips, ci="sd")
......@@ -232,7 +232,7 @@ Show standard deviation of observations instead of a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-pointplot-12.png](img/f41526e37f8f11614ea339da0e242c51.jpg)
Add “caps” to the error bars:
将“上下限指示线”增加到误差线的顶部和底部:
```py
>>> ax = sns.pointplot(x="day", y="tip", data=tips, capsize=.2)
......@@ -241,7 +241,7 @@ Add “caps” to the error bars:
![http://seaborn.pydata.org/_images/seaborn-pointplot-13.png](img/b7df4cf62c681ea39bd145bdb740bc81.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")[`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot") 以及 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")结合使用。这允许您通过额外的分类变量进行分组。使用 [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") 比直接使用 [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 更为安全,因为它保证了不同切面上变量同步的顺序:
```py
>>> g = sns.catplot(x="sex", y="total_bill",
......
......@@ -23,62 +23,61 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
这个函数始终把一个变量当做分类变量,即使这个数据是数值类型或者日期类型,并且按照序数顺序绘制在相关的轴上。
详情请看[教程](../tutorial/categorical.html#categorical-tutorial)
| Parameters: | **x, y, hue** : `data` 中的变量名词或者向量, optional
参数:`x, y, hue``data` 中的变量名词或者向量, optional
> 用于绘制long-form数据的变量名称.
**data** : DataFrame, 数组, 数组列表, optional
`data`DataFrame, 数组, 数组列表, optional
> 用于绘图的数据集。如果数据集有x和y,数据集会被认为是long-form,否则会被认为是wide-form。
**order, hue_order** : 字符串列表, optional
`order, hue_order`字符串列表, optional
> 绘制类别变量的顺序,如果没有,则从数据对象中推断绘图顺序。
**estimator** : 映射向量 -&gt; 标量, optional
`estimator`映射向量 -&gt; 标量, optional
> 统计函数用于估计每个分类纸条中的值。.
**ci** : float or “sd” or None, optional
`ci`float or “sd” or None, optional
> 估计值周围的置信区间大小。如果输入的是 “sd”(标准差),会跳过bootstrapping的过程,只绘制数据的标准差。 如果输入是的是`None`, 不会执行botstrapping,而且错误条也不会绘制。
**n_boot** : int, optional
`n_boot`int, optional
> 计算置信区间需要的Boostrap迭代次数。
**units** : name of variable in `data` or vector data, optional
`units`name of variable in `data` or vector data, optional
> 采样单元的标识符,用于执行多级bootstrap并解释重复测量设计。
**orient** : “v” &#124; “h”, optional
`orient`“v” &#124; “h”, optional
> 绘图的方向(垂直或水平)。这通常是从输入变量的数据类型推断出来的,但是可以用来指定“分类”变量是数字还是宽格式数据。
**color** : matplotlib color, optional
`color`matplotlib color, optional
> 作用于所有元素的颜色,或者渐变色的种子。
**palette** : palette name, list, or dict, optional
`palette`palette name, list, or dict, optional
> 不同级别的 `hue` 变量的颜色。 颜色要能被 [`color_palette()`]解释(seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), 或者一个能映射到matplotlib颜色的字典。
**saturation** : float, optional
`saturation`float, optional
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
**errcolor** : matplotlib color
`errcolor`matplotlib color
> 表示置信区间的线的颜色。
**errwidth** : float, optional
`errwidth`float, optional
> 误差条的线的厚度。
**capsize** : float, optional
`capsize`float, optional
> 误差条端部的宽度。
......@@ -86,22 +85,19 @@ seaborn.barplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None,
> When hue nesting is used, whether elements should be shifted along the categorical axis.
**ax** : matplotlib Axes, optional
`ax`matplotlib Axes, optional
> 指定一个Axes用于绘图,如果不指定,则使用当前的Axes。
**kwargs** : key, value mappings
`kwargs`key, value mappings
> 其他的关键词参数在绘图时通过 `plt.bar` 传入。
|
| --- | --- |
| 返回值: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib Axes
> 返回有图表绘制的Axes对象。
|
| --- | --- |
See also
......
# seaborn.countplot
> 译者:[Stuming](https://github.com/Stuming)
```py
seaborn.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)
```
Show the counts of observations in each categorical bin using bars.
seaborn.countplot使用条形图显示每个类别中观测值的数量。
这个函数可以被认为是针对类别变量的直方图。基本的API和选项与[`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot")完全相同,因此可以对比学习。
可以通过多种格式传入数据,包括:
* 通过列表、numpy数组、或者pandas Series对象表示的向量数据,数据直接传给`x`, `y`, 和/或`hue`参数。
* 长格式的DataFrame,此时会通过`x`, `y`以及`hue`变量决定如何绘制数据。
* 宽格式的DataFrame,此时每个数值型的column都会被绘制。
* 数组或者列表形式的向量
A count plot can be thought of as a histogram across a categorical, instead of quantitative, variable. The basic API and options are identical to those for [`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot"), so you can compare counts across nested variables.
在绝大多数情况下,数据格式都可以使用numpy或者Python对象,但是推荐使用pandas对象,因为pandas对象中相关的名称会被用于注释坐标轴。此外,可以通过设置分组变量为使用Categorical类型来控制绘制元素的顺序。
Input data can be passed in a variety of formats, including:
这个函数总会将变量作为类别变量进行处理,按顺序(0, 1, ... n)在相应坐标轴绘制数据,即使数据为数值或者日期类型。
* Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the `x`, `y`, and/or `hue` parameters.
* A “long-form” DataFrame, in which case the `x`, `y`, and `hue` variables will determine how the data are plotted.
* A “wide-form” DataFrame, such that each numeric column will be plotted.
* An array or list of vectors.
更多信息参考[tutorial](../tutorial/categorical.html#categorical-tutorial).
In most cases, it is possible to use numpy or Python objects, but pandas objects are preferable because the associated names will be used to annotate the axes. Additionally, you can use Categorical types for the grouping variables to control the order of plot elements.
参数:`x, y, hue`: `data`或者向量数据中的变量名,可选
This function always treats one of the variables as categorical and draws data at ordinal positions (0, 1, … n) on the relevant axis, even when the data has a numeric or date type.
> 用于绘制长格式数据的输入。查看解释示例
See the [tutorial](../tutorial/categorical.html#categorical-tutorial) for more information.
`data`:DataFrame, 数组,或者包含数组的列表,可选
| Parameters: | **x, y, hue** : names of variables in `data` or vector data, optional
> 用于绘制的数据集。如果`x`和`y`不存在,那么会将数据按宽格式进行处理,否则应当为长格式。
> Inputs for plotting long-form data. See examples for interpretation.
`order, hue_order`:包含字符串的列表,可选
**data** : DataFrame, array, or list of arrays, optional
> 类别层级绘制的顺序,否则层级会从数据对象中推测。
> Dataset for plotting. If `x` and `y` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
`orient`: “v” &#124; “h”, 可选
**order, hue_order** : lists of strings, optional
> 绘制的朝向(竖直或者水平)。通过从输入变量的dtype进行推断。当类别变量是数值型或者绘制宽格式数据时,可以进行指定。
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
`color`: matplotlib颜色,可选
**orient** : “v” &#124; “h”, optional
> 所有元素的颜色,或者渐变调色盘的种子。
> Orientation of the plot (vertical or horizontal). This is usually inferred from the dtype of the input variables, but can be used to specify when the “categorical” variable is a numeric or when plotting wide-form data.
`palette`: 调色盘名称,列表或字典,可选
**color** : matplotlib color, optional
> 用于`hue`变量的不同级别的颜色。应当是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者将色调级别映射到matplotlib颜色的字典。
> Color for all of the elements, or seed for a gradient palette.
`saturation`: float, 可选
**palette** : palette name, list, or dict, optional
> 在原有饱和度的比例下绘制颜色。大片的图块通常在略微不饱和的颜色下看起来更好,而如果想要绘制的颜色与输入颜色规格完全匹配,应当设置此值为`1`。
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
`dodge`: bool, 可选
**saturation** : float, optional
> 当使用色调嵌套时,决定是否沿着类别轴对元素进行移位。
> Proportion of the original saturation to draw colors at. Large patches often look better with slightly desaturated colors, but set this to `1` if you want the plot colors to perfectly match the input color spec.
`ax`: matplotlib轴,可选
**dodge** : bool, optional
> 绘制图像的轴对象,不指定时使用当前轴。
> When hue nesting is used, whether elements should be shifted along the categorical axis.
`kwargs`: 键值映射
**ax** : matplotlib Axes, optional
> 其他关键字参数会被传递给`plt.bar`.
> Axes object to draw the plot onto, otherwise uses the current Axes.
**kwargs** : key, value mappings
返回值:`ax`: matplotlib轴
> Other keyword arguments are passed to `plt.bar`.
> 返回带有绘图的轴对象。
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
|
| --- | --- |
另请参阅
See also
[`barplot()`](seaborn.barplot.html#seaborn.barplot "seaborn.barplot"): 使用条形图显示点估计和置信区间。
Show point estimates and confidence intervals using bars.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
[`factorplot()`](seaborn.factorplot.html#seaborn.factorplot "seaborn.factorplot"): 结合类别图与`FacetGrid`类。
Examples
示例
Show value counts for a single categorical variable:
显示单个类别变量的计数值:
```py
>>> import seaborn as sns
......@@ -88,7 +90,7 @@ Show value counts for a single categorical variable:
![http://seaborn.pydata.org/_images/seaborn-countplot-1.png](img/840a3b4206930d48fae0f0d4549b87a0.jpg)
Show value counts for two categorical variables:
显示两个类别变量的计数值:
```py
>>> ax = sns.countplot(x="class", hue="who", data=titanic)
......@@ -97,7 +99,7 @@ Show value counts for two categorical variables:
![http://seaborn.pydata.org/_images/seaborn-countplot-2.png](img/7fde400b120a0b6cd6aca0cb2de690db.jpg)
Plot the bars horizontally:
水平绘制条形图:
```py
>>> ax = sns.countplot(y="class", hue="who", data=titanic)
......@@ -106,7 +108,7 @@ Plot the bars horizontally:
![http://seaborn.pydata.org/_images/seaborn-countplot-3.png](img/512afaa1b09caf55faf909a34995137a.jpg)
Use a different color palette:
使用不同的颜色色盘:
```py
>>> ax = sns.countplot(x="who", data=titanic, palette="Set3")
......@@ -115,7 +117,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-countplot-4.png](img/d3ac1e2e1f590489ef76341664562f87.jpg)
Use `plt.bar` keyword arguments for a different look:
使用`plt.bar`的关键字参数获得不同的显示效果:
```py
>>> ax = sns.countplot(x="who", data=titanic,
......@@ -127,7 +129,7 @@ Use `plt.bar` keyword arguments for a different look:
![http://seaborn.pydata.org/_images/seaborn-countplot-5.png](img/d23d0851c88c12754e0c1e08aac20d01.jpg)
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") to combine a [`countplot()`](#seaborn.countplot "seaborn.countplot") and a [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid"). This allows grouping within additional categorical variables. Using [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot") is safer than using [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") directly, as it ensures synchronization of variable order across facets:
使用[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")实现结合[`countplot()`](#seaborn.countplot "seaborn.countplot")以及[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的效果。这样做可以在额外的类别变量中进行分组。使用[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")比直接使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")更加安全,因为这样做可以确保跨分面的变量顺序同步:
```py
>>> g = sns.catplot(x="class", hue="who", col="survived",
......
......@@ -8,62 +8,60 @@ Draw a plot of two variables with bivariate and univariate graphs.
This function provides a convenient interface to the [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") class, with several canned plot kinds. This is intended to be a fairly lightweight wrapper; if you need more flexibility, you should use [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") directly.
| Parameters: | **x, y** : strings or vectors
参数:`x, y`strings or vectors
> Data or names of variables in `data`.
**data** : DataFrame, optional
`data`DataFrame, optional
> DataFrame when `x` and `y` are variable names.
**kind** : { “scatter” &#124; “reg” &#124; “resid” &#124; “kde” &#124; “hex” }, optional
`kind`{ “scatter” &#124; “reg” &#124; “resid” &#124; “kde” &#124; “hex” }, optional
> Kind of plot to draw.
**stat_func** : callable or None, optional
`stat_func`callable or None, optional
> _Deprecated_
**color** : matplotlib color, optional
`color`matplotlib color, optional
> Color used for the plot elements.
**height** : numeric, optional
`height`numeric, optional
> Size of the figure (it will be square).
**ratio** : numeric, optional
`ratio`numeric, optional
> Ratio of joint axes height to marginal axes height.
**space** : numeric, optional
`space`numeric, optional
> Space between the joint and marginal axes
**dropna** : bool, optional
`dropna`bool, optional
> If True, remove observations that are missing from `x` and `y`.
**{x, y}lim** : two-tuples, optional
`{x, y}lim`two-tuples, optional
> Axis limits to set before plotting.
**{joint, marginal, annot}_kws** : dicts, optional
`{joint, marginal, annot}_kws`dicts, optional
> Additional keyword arguments for the plot components.
**kwargs** : key, value pairings
`kwargs`key, value pairings
> Additional keyword arguments are passed to the function used to draw the plot on the joint Axes, superseding items in the `joint_kws` dictionary.
|
| --- | --- |
| Returns: | **grid** : [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")
返回值:`grid`[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")
> [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") object with the plot on it.
|
| --- | --- |
See also
......
......@@ -12,66 +12,64 @@ It is also possible to show a subset of variables or plot different variables on
This is a high-level interface for [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") that is intended to make it easy to draw a few common styles. You should use [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") directly if you need more flexibility.
| Parameters: | **data** : DataFrame
参数:`data`DataFrame
> Tidy (long-form) dataframe where each column is a variable and each row is an observation.
**hue** : string (variable name), optional
`hue`string (variable name), optional
> Variable in `data` to map plot aspects to different colors.
**hue_order** : list of strings
`hue_order`list of strings
> Order for the levels of the hue variable in the palette
**palette** : dict or seaborn color palette
`palette`dict or seaborn color palette
> Set of colors for mapping the `hue` variable. If a dict, keys should be values in the `hue` variable.
**vars** : list of variable names, optional
`vars`list of variable names, optional
> Variables within `data` to use, otherwise use every column with a numeric datatype.
**{x, y}_vars** : lists of variable names, optional
`{x, y}_vars`lists of variable names, optional
> Variables within `data` to use separately for the rows and columns of the figure; i.e. to make a non-square plot.
**kind** : {‘scatter’, ‘reg’}, optional
`kind`{‘scatter’, ‘reg’}, optional
> Kind of plot for the non-identity relationships.
**diag_kind** : {‘auto’, ‘hist’, ‘kde’}, optional
`diag_kind`{‘auto’, ‘hist’, ‘kde’}, optional
> Kind of plot for the diagonal subplots. The default depends on whether `"hue"` is used or not.
**markers** : single matplotlib marker code or list, optional
`markers`single matplotlib marker code or list, optional
> Either the marker to use for all datapoints or a list of markers with a length the same as the number of levels in the hue variable so that differently colored points will also have different scatterplot markers.
**height** : scalar, optional
`height`scalar, optional
> Height (in inches) of each facet.
**aspect** : scalar, optional
`aspect`scalar, optional
> Aspect * height gives the width (in inches) of each facet.
**dropna** : boolean, optional
`dropna`boolean, optional
> Drop missing values from the data before plotting.
**{plot, diag, grid}_kws** : dicts, optional
`{plot, diag, grid}_kws`dicts, optional
> Dictionaries of keyword arguments.
|
| --- | --- |
| Returns: | **grid** : PairGrid
返回值:`grid`:PairGrid
> Returns the underlying `PairGrid` instance for further tweaking.
|
| --- | --- |
See also
......
# seaborn.distplot
# seaborn.distplot
> 译者:[hyuuo](https://github.com/hyuuo)
```py
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)
```
Flexibly plot a univariate distribution of observations.
灵活绘制单变量观测值分布图。
该函数结合了matplotlib中的 `hist`函数(自动计算一个默认的合适的bin大小)、seaborn的[`kdeplot()`](seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")[`rugplot()`](seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot")函数。它还可以拟合`scipy.stats`分布并在数据上绘制估计的PDF(概率分布函数)。
This function combines the matplotlib `hist` function (with automatic calculation of a good default bin size) with the seaborn [`kdeplot()`](seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot") and [`rugplot()`](seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot") functions. It can also fit `scipy.stats` distributions and plot the estimated PDF over the data.
参数:`a`:Series、1维数组或者列表。
| Parameters: | **a** : Series, 1d-array, or list.
> 观察数据。如果是具有`name`属性的Series对象,则该名称将用于标记数据轴。
> Observed data. If this is a Series object with a `name` attribute, the name will be used to label the data axis.
`bins`:matplotlib hist()的参数,或None。可选参数。
**bins** : argument for matplotlib hist(), or None, optional
> 直方图bins(柱)的数目,若填None,则默认使用Freedman-Diaconis规则指定柱的数目。
> Specification of hist bins, or None to use Freedman-Diaconis rule.
`hist`:布尔值,可选参数。
**hist** : bool, optional
> 是否绘制(标准化)直方图。
> Whether to plot a (normed) histogram.
`kde`:布尔值,可选参数。
**kde** : bool, optional
> 是否绘制高斯核密度估计图。
> Whether to plot a gaussian kernel density estimate.
`rug`:布尔值,可选参数。
**rug** : bool, optional
> 是否在横轴上绘制观测值竖线。
> Whether to draw a rugplot on the support axis.
`fit`:随机变量对象,可选参数。
**fit** : random variable object, optional
> 一个带有*fit*方法的对象,返回一个元组,该元组可以传递给*pdf*方法一个位置参数,该位置参数遵循一个值的网格用于评估pdf。
> An object with &lt;cite&gt;fit&lt;/cite&gt; method, returning a tuple that can be passed to a &lt;cite&gt;pdf&lt;/cite&gt; method a positional arguments following an grid of values to evaluate the pdf on.
`{hist, kde, rug, fit}_kws`:字典,可选参数。
**{hist, kde, rug, fit}_kws** : dictionaries, optional
> 底层绘图函数的关键字参数。
> Keyword arguments for underlying plotting functions.
`color`:matplotlib color,可选参数。
**color** : matplotlib color, optional
> 可以绘制除了拟合曲线之外所有内容的颜色。
> Color to plot everything but the fitted curve in.
`vertical`:布尔值,可选参数。
**vertical** : bool, optional
> 如果为True,则观测值在y轴显示。
> If True, observed values are on y-axis.
`norm_hist`:布尔值,可选参数。
**norm_hist** : bool, optional
> 如果为True,则直方图的高度显示密度而不是计数。如果绘制KDE图或拟合密度,则默认为True。
> If True, the histogram height shows a density rather than a count. This is implied if a KDE or fitted density is plotted.
`axlabel`:字符串,False或者None,可选参数。
**axlabel** : string, False, or None, optional
> 横轴的名称。如果为None,将尝试从a.name获取它;如果为False,则不设置标签。
> Name for the support axis label. If None, will try to get it from a.namel if False, do not set a label.
`label`:字符串,可选参数。
**label** : string, optional
> 图形相关组成部分的图例标签。
> Legend label for the relevent component of the plot
`ax`:matplotlib axis,可选参数。
**ax** : matplotlib axis, optional
> 若提供该参数,则在参数设定的轴上绘图。
> if provided, plot on this axis
返回值:`ax`:matplotlib Axes
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 返回Axes对象以及用于进一步调整的绘图。
> Returns the Axes object with the plot for further tweaking.
**另请参见**
|
| --- | --- |
[`kdeplot`](seaborn.kdeplot.html#seaborn.kdeplot "seaborn.kdeplot")
See also
显示具有核密度估计图的单变量或双变量分布。
Show a univariate or bivariate distribution with a kernel density estimate.Draw small vertical lines to show each observation in a distribution.
[`rugplot`](seaborn.rugplot.html#seaborn.rugplot "seaborn.rugplot")
Examples
绘制小的垂直线以显示分布中的每个观测值。
Show a default plot with a kernel density estimate and histogram with bin size determined automatically with a reference rule:
**范例**
显示具有核密度估计的默认图和使用参考规则自动确定bin大小的直方图:
```py
>>> import seaborn as sns, numpy as np
>>> sns.set(); np.random.seed(0)
......@@ -84,10 +86,9 @@ Show a default plot with a kernel density estimate and histogram with bin size d
>>> ax = sns.distplot(x)
```
![http://seaborn.pydata.org/_images/seaborn-distplot-1.png](img/dfbc2ec93ea21c479448cd2e25976945.jpg)
Use Pandas objects to get an informative axis label:
使用Pandas对象获取信息轴标签:
```py
>>> import pandas as pd
......@@ -98,7 +99,7 @@ Use Pandas objects to get an informative axis label:
![http://seaborn.pydata.org/_images/seaborn-distplot-2.png](img/d33f6bf00c0886595c68d970316b0717.jpg)
Plot the distribution with a kernel density estimate and rug plot:
使用核密度估计和小的垂直线绘制分布图:
```py
>>> ax = sns.distplot(x, rug=True, hist=False)
......@@ -107,7 +108,7 @@ Plot the distribution with a kernel density estimate and rug plot:
![http://seaborn.pydata.org/_images/seaborn-distplot-3.png](img/85548cb1190d0ad63fbaf33d0966b16d.jpg)
Plot the distribution with a histogram and maximum likelihood gaussian distribution fit:
使用直方图和最大似然高斯分布拟合绘制分布图:
```py
>>> from scipy.stats import norm
......@@ -117,7 +118,7 @@ Plot the distribution with a histogram and maximum likelihood gaussian distribut
![http://seaborn.pydata.org/_images/seaborn-distplot-4.png](img/d3a9c4026d4ce70e54b250057cd2062b.jpg)
Plot the distribution on the vertical axis:
在垂直轴上绘制分布图:
```py
>>> ax = sns.distplot(x, vertical=True)
......@@ -126,7 +127,7 @@ Plot the distribution on the vertical axis:
![http://seaborn.pydata.org/_images/seaborn-distplot-5.png](img/0a53d5e52e4ce61295a6c2b5fc4bf6c8.jpg)
Change the color of all the plot elements:
更改所有绘图元素的颜色:
```py
>>> sns.set_color_codes()
......@@ -136,7 +137,7 @@ Change the color of all the plot elements:
![http://seaborn.pydata.org/_images/seaborn-distplot-6.png](img/fac6ba03c6573e299e4eee00c32999fb.jpg)
Pass specific parameters to the underlying plot functions:
将特定参数传递给基础绘图函数:
```py
>>> ax = sns.distplot(x, rug=True, rug_kws={"color": "g"},
......@@ -146,4 +147,4 @@ Pass specific parameters to the underlying plot functions:
```
![http://seaborn.pydata.org/_images/seaborn-distplot-7.png](img/fce8e5a984297be3f6f8b5d4c5369a78.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-distplot-7.png](img/fce8e5a984297be3f6f8b5d4c5369a78.jpg)
# seaborn.kdeplot
> 译者:[hyuuo](https://github.com/hyuuo)
```py
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)
```
Fit and plot a univariate or bivariate kernel density estimate.
拟合并绘制单变量或双变量核密度估计图。
参数:`data`:一维阵列
> 输入数据
| Parameters: | **data** : 1d array-like
**data2:一维阵列,可选。
> Input data.
> 第二输入数据。如果存在,将估计双变量KDE。
**data2: 1d array-like, optional**
`shade`:布尔值,可选参数。
> Second input data. If present, a bivariate KDE will be estimated.
> 如果为True,则在KDE曲线下方的区域中增加阴影(或者在数据为双变量时使用填充的轮廓绘制)。
**shade** : bool, optional
`vertical`:布尔值,可选参数。
> If True, shade in the area under the KDE curve (or draw with filled contours when data is bivariate).
> 如果为True,密度图将显示在x轴。
**vertical** : bool, optional
`kernel`:{‘gau’ &#124; ‘cos’ &#124; ‘biw’ &#124; ‘epa’ &#124; ‘tri’ &#124; ‘triw’ },可选参数
> If True, density is on x-axis.
> 要拟合的核的形状代码,双变量KDE只能使用高斯核。
**kernel** : {‘gau’ &#124; ‘cos’ &#124; ‘biw’ &#124; ‘epa’ &#124; ‘tri’ &#124; ‘triw’ }, optional
`bw`:{‘scott’ &#124; ‘silverman’ &#124; scalar &#124; pair of scalars },可选参数
> Code for shape of kernel to fit with. Bivariate KDE can only use gaussian kernel.
> 用于确定双变量图的每个维的核大小、标量因子或标量的参考方法的名称。需要注意的是底层的计算库对此参数有不同的交互:`statsmodels`直接使用它,而`scipy`将其视为数据标准差的缩放因子。
**bw** : {‘scott’ &#124; ‘silverman’ &#124; scalar &#124; pair of scalars }, optional
`gridsize`:整型数据,可选参数。
> Name of reference method to determine kernel size, scalar factor, or scalar for each dimension of the bivariate plot. Note that the underlying computational libraries have different interperetations for this parameter: `statsmodels` uses it directly, but `scipy` treats it as a scaling factor for the standard deviation of the data.
> 评估网格中的离散点数。
**gridsize** : int, optional
`cut`:标量,可选参数。
> Number of discrete points in the evaluation grid.
> 绘制估计值以从极端数据点切割* bw。
**cut** : scalar, optional
`clip`:一对标量,可选参数。
> Draw the estimate to cut * bw from the extreme data points.
> 用于拟合KDE图的数据点的上下限值。可以为双变量图提供一对(上,下)边界。
**clip** : pair of scalars, or pair of pair of scalars, optional
`legend`:布尔值,可选参数。
> Lower and upper bounds for datapoints used to fit KDE. Can provide a pair of (low, high) bounds for bivariate plots.
> 如果为True,为绘制的图像添加图例或者标记坐标轴。
**legend** : bool, optional
`cumulative`:布尔值,可选参数。
> If True, add a legend or label the axes when possible.
> 如果为True,则绘制kde估计图的累积分布。
**cumulative** : bool, optional
`shade_lowest`:布尔值,可选参数。
> If True, draw the cumulative distribution estimated by the kde.
> 如果为True,则屏蔽双变量KDE图的最低轮廓。绘制单变量图或“shade = False”时无影响。当你想要在同一轴上绘制多个密度时,可将此参数设置为“False”。
**shade_lowest** : bool, optional
`cbar`:布尔值,可选参数。
> 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.
> 如果为True并绘制双变量KDE图,为绘制的图像添加颜色条。
**cbar** : bool, optional
`cbar_ax`:matplotlib axes,可选参数。
> If True and drawing a bivariate KDE plot, add a colorbar.
> 用于绘制颜色条的坐标轴,若为空,就在主轴绘制颜色条。
**cbar_ax** : matplotlib axes, optional
`cbar_kws`:字典,可选参数。
> Existing axes to draw the colorbar onto, otherwise space is taken from the main axes.
> `fig.colorbar()`的关键字参数。
**cbar_kws** : dict, optional
`ax`:matplotlib axes,可选参数。
> Keyword arguments for `fig.colorbar()`.
> 要绘图的坐标轴,若为空,则使用当前轴。
**ax** : matplotlib axes, optional
`kwargs`:键值对
> Axes to plot on, otherwise uses current axes.
> 其他传递给`plt.plot()`或`plt.contour {f}`的关键字参数,具体取决于是绘制单变量还是双变量图。
**kwargs** : key, value pairings
返回值:`ax`:matplotlib Axes
> 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** : matplotlib Axes
**另请参见**
> Axes with plot.
[`distplot`](seaborn.distplot.html#seaborn.distplot "seaborn.distplot")
|
| --- | --- |
灵活绘制单变量观测值分布图。
See also
[`jointplot`](seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")
Flexibly plot a univariate distribution of observations.Plot a joint dataset with bivariate and marginal distributions.
绘制一个具有双变量和边缘分布的联合数据集。
Examples
范例
Plot a basic univariate density:
绘制一个简单的单变量分布:
```py
>>> import numpy as np; np.random.seed(10)
......@@ -102,7 +105,7 @@ Plot a basic univariate density:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-1.png](img/467839dfd41d95bdf1eb6d992d54a81f.jpg)
Shade under the density curve and use a different color:
在密度曲线下使用不同的颜色着色:
```py
>>> ax = sns.kdeplot(x, shade=True, color="r")
......@@ -111,7 +114,7 @@ Shade under the density curve and use a different color:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-2.png](img/98bd4d30d5719cd930a50603d08aa30e.jpg)
Plot a bivariate density:
绘制一个双变量分布:
```py
>>> ax = sns.kdeplot(x, y)
......@@ -120,7 +123,7 @@ Plot a bivariate density:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-3.png](img/1a4a764cf63a098fe9db3dc317e88058.jpg)
Use filled contours:
使用填充轮廓:
```py
>>> ax = sns.kdeplot(x, y, shade=True)
......@@ -129,7 +132,7 @@ Use filled contours:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-4.png](img/566a36de7b39f66e34fa323e7153fa42.jpg)
Use more contour levels and a different color palette:
使用更多的轮廓级别和不同的调色板:
```py
>>> ax = sns.kdeplot(x, y, n_levels=30, cmap="Purples_d")
......@@ -138,7 +141,7 @@ Use more contour levels and a different color palette:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-5.png](img/73c68c911f3d8aaf827238e97a8dc560.jpg)
Use a narrower bandwith:
使用窄带宽:
```py
>>> ax = sns.kdeplot(x, bw=.15)
......@@ -147,7 +150,7 @@ Use a narrower bandwith:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-6.png](img/cf85bc1dbfbb0399b3008f079b88d570.jpg)
Plot the density on the vertical axis:
在纵轴上绘制密度分布:
```py
>>> ax = sns.kdeplot(y, vertical=True)
......@@ -156,7 +159,7 @@ Plot the density on the vertical axis:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-7.png](img/62b886998fa52840a228f283aa862506.jpg)
Limit the density curve within the range of the data:
将密度曲线限制在数据范围内:
```py
>>> ax = sns.kdeplot(x, cut=0)
......@@ -165,7 +168,7 @@ Limit the density curve within the range of the data:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-8.png](img/1d21f3969de9de67e8acd0e2486c5e04.jpg)
Add a colorbar for the contours:
为轮廓添加一个颜色条:
```py
>>> ax = sns.kdeplot(x, y, cbar=True)
......@@ -174,7 +177,7 @@ Add a colorbar for the contours:
![http://seaborn.pydata.org/_images/seaborn-kdeplot-9.png](img/341dd0f98ddca59219e6289b038c8784.jpg)
Plot two shaded bivariate densities:
为双变量密度图绘制两个阴影:
```py
>>> iris = sns.load_dataset("iris")
......@@ -187,4 +190,4 @@ Plot two shaded bivariate densities:
```
![http://seaborn.pydata.org/_images/seaborn-kdeplot-10.png](img/6ffe5e9bcaba45c14f423cae61e6e743.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-kdeplot-10.png](img/6ffe5e9bcaba45c14f423cae61e6e743.jpg)
# seaborn.rugplot
> 译者:[P3n9W31](https://github.com/P3n9W31)
```py
seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)
```
Plot datapoints in an array as sticks on an axis.
将数组中的数据点绘制为轴上的棒状标识。
参数:`a`:向量
| Parameters: | **a** : vector
> 1维的观察数组。
> 1D array of observations.
`height`:标量, 可选
**height** : scalar, optional
> 以比例形式表示的坐标轴上棒状标识的高度。
> Height of ticks as proportion of the axis.
`axis`:{‘x’ &#124; ‘y’}, 可选
**axis** : {‘x’ &#124; ‘y’}, optional
> 需要画rugplot的坐标轴
> Axis to draw rugplot on.
`ax`:matplotlib 轴, 可选
**ax** : matplotlib axes, optional
> 进行绘制的坐标轴; 未指定的话设定为当前轴。
> Axes to draw plot into; otherwise grabs current axes.
`kwargs`:键值对
**kwargs** : key, value pairings
> 被传递给`LineCollection`的其他关键字参数。
> Other keyword arguments are passed to `LineCollection`.
|
| --- | --- |
| Returns: | **ax** : matplotlib axes
返回值:`ax`:matplotlib Axex对象
> The Axes object with the plot on it.
> 在其上进行绘图的Axex对象。
|
| --- | --- |
\ No newline at end of file
此差异已折叠。
# seaborn.regplot
> 译者:[P3n9W31](https://github.com/P3n9W31)
```py
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)
```
Plot data and a linear regression model fit.
绘制数据和线性回归模型拟合。
估算回归模型有许多互斥的选项。查看这个[教程](../tutorial/regression.html#regression-tutorial) 来了解更多的信息。
参数:**x,y:字符串,序列(series)或者是向量数组(vector array)**
There are a number of mutually exclusive options for estimating the regression model. See the [tutorial](../tutorial/regression.html#regression-tutorial) for more information.
> 输入变量。 如果是字符串,应该与`data`中的列名相对应。 使用pandas对象时,轴将被Series的名字标记。
| Parameters: | **x, y: string, series, or vector array**
`data`:DataFrame
> 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.
> Tidy (“long-form”)格式的DataFrame,其中每列为一个变量,每行为一个观测样本。
**data** : DataFrame
`x_estimator`:可调用的映射向量 -&gt;标量,可选
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
> 将此函数应用于`x`的每个唯一值并绘制结果的估计值。当`x`是离散变量时,这是十分有用的。如果给出`x_ci`,则该估计将被引导并且将绘制置信区间。
**x_estimator** : callable that maps vector -&gt; scalar, optional
`x_bins`:整数或向量,可选
> 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`变量加入离散区间,然后估计中心趋势和置信区间。 此分箱仅影响散点图的绘制方式; 回归仍然适合原始数据。该参数被解释为均匀大小(不必要间隔)的箱的数量或箱中心的位置。使用此参数时,它意味着`x_estimator`的默认值为`numpy.mean`。
**x_bins** : int or vector, optional
`x_ci`:"ci",'sd',位于 [0, 100]之间的整数或None,可选
> 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”,则跳过bootstrapping并显示每个bin中观察值的标准偏差。
**x_ci** : “ci”, “sd”, int in [0, 100] or None, optional
`scatter`:布尔值,可选
> 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 bootstrapping and show the standard deviation of the observations in each bin.
> 如果为 `True`,则绘制带有基础观测值(或`x_estimator` 值)的散点图。
**scatter** : bool, optional
`fit_reg`:布尔值,可选
> If `True`, draw a scatterplot with the underlying observations (or the `x_estimator` values).
> 如果为 `True`,则估计并绘制与 `x` 和 `y` 变量相关的回归模型。
**fit_reg** : bool, optional
`ci`:位于 [0, 100]之间的整数或None,可选
> If `True`, estimate and plot a regression model relating the `x` and `y` variables.
> 回归估计的置信区间的大小。这将使用回归线周围的半透明带绘制。 使用自助法(bootstrap)估计置信区间; 对于大型数据集,建议通过将此参数设置为None来避免该计算。
**ci** : int in [0, 100] or None, optional
`n_boot`:整数,可选
> 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.
> 用于估计`ci`的自助法(bootstrap)重采样数。 默认值试图在时间和稳定性之间找到平衡; 你可能希望为“最终”版本的图像增加此值。
**n_boot** : int, optional
`units``data`,中的变量名,可选
> 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.
> 如果`x`和`y`观察结果嵌套在采样单元中,则可以在此处指定。在通过对所有的单元和观察样本(在单元内)执行重新采样的多级自助法(multilevel bootstrap)来计算置信区间时将考虑这一点。 否则,这不会影响估计或绘制回归的方式。
**units** : variable name in `data`, optional
`order`:整数,可选
> 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`大于1,使用`numpy.polyfit`来估计多项式回归。
**order** : int, optional
`logistic`:布尔值,可选
> If `order` is greater than 1, use `numpy.polyfit` to estimate a polynomial regression.
> 如果为“True”,则假设`y`是二元变量并使用`statsmodels`来估计逻辑回归模型。 请注意,这比线性回归的计算密集程度要大得多,因此您可能希望减少引导程序重新采样(`n_boot`)的数量或将 `ci`设置为“无”。
**logistic** : bool, optional
`lowess`:布尔值,可选
> 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.
> 如果为“True”,则使用`statsmodels`来估计非参数lowess模型(局部加权线性回归)。 请注意,目前无法为此类模型绘制置信区间。
**lowess** : bool, optional
`robust`:布尔值,可选
> 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.
> 如果为“True”,则使用`statsmodels`来估计稳健回归。 这将削弱异常值。 请注意,这比标准线性回归的计算密集程度要大得多,因此您可能希望减少引导程序重新采样(`n_boot`)的数量或将 `ci`设置为“无”。
**robust** : bool, optional
`logx`:布尔值,可选
> 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.
> 如果为 `True`,则估计形式y~log(x)的线性回归,但在输入空间中绘制散点图和回归模型。 请注意,`x`必须为正才能正常工作。
**logx** : bool, optional
`{x,y}_partial``data` 中的字符串或矩阵
> 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.
> 混淆(Confounding)变量以在绘图之前退回`x`或`y`变量。
**{x,y}_partial** : strings in `data` or matrices
`truncate`:布尔值,可选
> Confounding variables to regress out of the `x` or `y` variables before plotting.
> 默认情况下,绘制回归线以在绘制散点图后填充x轴限制。 如果`truncate`是`True`,它将改为受到数据本身限制的限制。
**truncate** : bool, optional
`{x,y}_jitter`:浮点数,可选
> 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”变量中。 在拟合回归之后,噪声被添加到数据的副本中,并且仅影响散点图的外观。 在绘制采用离散值的变量时,这会很有用。
**{x,y}_jitter** : floats, optional
`label`:字符串
> 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.
> 要应用于散点图或回归线(如果`scatter`为'False`)的标签,以便在图例中使用。
**label** : string
`color`:matplotlib 颜色
> Label to apply to ether the scatterplot or regression line (if `scatter` is `False`) for use in a legend.
> 适用于所有绘图元素的颜色; 将被`scatter_kws`或`line_kws`中传递的颜色取代。
**color** : matplotlib color
`marker`:matplotlib标记代码或标记代码列表,可选
> Color to apply to all plot elements; will be superseded by colors passed in `scatter_kws` or `line_kws`.
> 散点图的标记。
**marker** : matplotlib marker code
`{scatter,line}_kws`:字典
> Marker to use for the scatterplot glyphs.
> 传递给`plt.scatter`和`plt.plot`的附加关键字参数。
**{scatter,line}_kws** : dictionaries
`ax`:matplotlib Axes对象,可选
> 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.
返回值:`ax`:matplotlib Axes对象
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
> 包含了图像的Axes对象。
> The Axes object containing the plot.
|
| --- | --- |
See also
也可以看看
Combine [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") to plot multiple linear relationships in a dataset.Combine [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") (when used with `kind="reg"`).Combine [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") (when used with `kind="reg"`).Plot the residuals of a linear regression model.
结合 [`regplot()`](#seaborn.regplot "seaborn.regplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid") 来绘制数据集中的多个线性关系。 结合 [`regplot()`](#seaborn.regplot "seaborn.regplot")[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") (与`kind="reg"`一起使用时)。结合 [`regplot()`](#seaborn.regplot "seaborn.regplot")[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") (当用于` kind =“reg”`)。绘制线性回归模型的残差。
Notes
注意
The [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`lmplot()`](seaborn.lmplot.html#seaborn.lmplot "seaborn.lmplot") functions are closely related, but the former is an axes-level function while the latter is a figure-level function that combines [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid").
[`regplot()`](#seaborn.regplot "seaborn.regplot")[`lmplot()`](seaborn.lmplot.html#seaborn.lmplot "seaborn.lmplot") 函数密切相关,但是前者是坐标轴级别的函数,而后者是结合了[`regplot()`](#seaborn.regplot "seaborn.regplot")[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")的图像级别的函数。
It’s also easy to combine combine [`regplot()`](#seaborn.regplot "seaborn.regplot") and [`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid") or [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") through the [`jointplot()`](seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot") and [`pairplot()`](seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot") functions, although these do not directly accept all of [`regplot()`](#seaborn.regplot "seaborn.regplot")’s parameters.
通过 [`jointplot()`](seaborn.jointplot.html#seaborn.jointplot "seaborn.jointplot")[`pairplot()`](seaborn.pairplot.html#seaborn.pairplot "seaborn.pairplot") 函数来组合 [`regplot()`](#seaborn.regplot "seaborn.regplot")[`JointGrid`](seaborn.JointGrid.html#seaborn.JointGrid "seaborn.JointGrid")[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") 是十分容易的,虽然这些函数不直接接受所有 [`regplot()`](#seaborn.regplot "seaborn.regplot")的参数。
Examples
例子
Plot the relationship between two variables in a DataFrame:
绘制DataFrame中两个变量之间的关系:
```py
>>> import seaborn as sns; sns.set(color_codes=True)
......@@ -132,7 +132,7 @@ Plot the relationship between two variables in a DataFrame:
![http://seaborn.pydata.org/_images/seaborn-regplot-1.png](img/99b1873131479cf9f24377991b06cbdb.jpg)
Plot with two variables defined as numpy arrays; use a different color:
利用两个定义为numpy数组的变量进行绘图; 使用不同的颜色:
```py
>>> import numpy as np; np.random.seed(8)
......@@ -144,7 +144,7 @@ Plot with two variables defined as numpy arrays; use a different color:
![http://seaborn.pydata.org/_images/seaborn-regplot-2.png](img/b6422e805157f85b21973dd3266dcb3f.jpg)
Plot with two variables defined as pandas Series; use a different marker:
利用两个定义为pandas Series的变量来进行绘图; 使用不同的标记:
```py
>>> import pandas as pd
......@@ -155,7 +155,7 @@ Plot with two variables defined as pandas Series; use a different marker:
![http://seaborn.pydata.org/_images/seaborn-regplot-3.png](img/2749fd423c61cc0419daeeec8d8aa467.jpg)
Use a 68% confidence interval, which corresponds with the standard error of the estimate:
使用68%置信区间,该区间对应于估计的标准误差:
```py
>>> ax = sns.regplot(x=x, y=y, ci=68)
......@@ -164,7 +164,7 @@ Use a 68% confidence interval, which corresponds with the standard error of the
![http://seaborn.pydata.org/_images/seaborn-regplot-4.png](img/17710001d51c2a58f06feca00a0eaa56.jpg)
Plot with a discrete `x` variable and add some jitter:
使用离散的`x`变量进行绘图并添加一些抖动:
```py
>>> ax = sns.regplot(x="size", y="total_bill", data=tips, x_jitter=.1)
......@@ -173,7 +173,7 @@ Plot with a discrete `x` variable and add some jitter:
![http://seaborn.pydata.org/_images/seaborn-regplot-5.png](img/823e73942bde25e25637964d2bcd7acf.jpg)
Plot with a discrete `x` variable showing means and confidence intervals for unique values:
绘制一个离散的`x`变量,显示唯一值的均值和置信区间:
```py
>>> ax = sns.regplot(x="size", y="total_bill", data=tips,
......@@ -183,7 +183,7 @@ Plot with a discrete `x` variable showing means and confidence intervals for uni
![http://seaborn.pydata.org/_images/seaborn-regplot-6.png](img/b2bb1b6b97e36328f09b122b92dd52bf.jpg)
Plot with a continuous variable divided into discrete bins:
将连续的变量划分为分离的区间并进行绘图:
```py
>>> ax = sns.regplot(x=x, y=y, x_bins=4)
......@@ -192,7 +192,7 @@ Plot with a continuous variable divided into discrete bins:
![http://seaborn.pydata.org/_images/seaborn-regplot-7.png](img/90def53f341cf365a39051cbb1e17f61.jpg)
Fit a higher-order polynomial regression and truncate the model prediction:
拟合高阶多项式回归并截断模型预测:
```py
>>> ans = sns.load_dataset("anscombe")
......@@ -204,7 +204,7 @@ Fit a higher-order polynomial regression and truncate the model prediction:
![http://seaborn.pydata.org/_images/seaborn-regplot-8.png](img/1eb024fe4ee82e1fd71c47c29ebf1856.jpg)
Fit a robust regression and don’t plot a confidence interval:
拟合稳健回归并且不绘制置信区间:
```py
>>> ax = sns.regplot(x="x", y="y", data=ans.loc[ans.dataset == "III"],
......@@ -215,7 +215,7 @@ Fit a robust regression and don’t plot a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-regplot-9.png](img/83369998db2c4eb1e99c856c538f5cb2.jpg)
Fit a logistic regression; jitter the y variable and use fewer bootstrap iterations:
对数据运用逻辑回归; 抖动y变量并使用较少的bootstrap迭代:
```py
>>> tips["big_tip"] = (tips.tip / tips.total_bill) > .175
......@@ -226,7 +226,7 @@ Fit a logistic regression; jitter the y variable and use fewer bootstrap iterati
![http://seaborn.pydata.org/_images/seaborn-regplot-10.png](img/b7d4fc0e5dd7fd0d56b558fc3316841a.jpg)
Fit the regression model using log(x) and truncate the model prediction:
使用 log(x) 拟合回归模型并截断模型预测:
```py
>>> ax = sns.regplot(x="size", y="total_bill", data=tips,
......
# seaborn.residplot
> 译者:[P3n9W31](https://github.com/P3n9W31)
```py
seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None, order=1, robust=False, dropna=True, label=None, color=None, scatter_kws=None, line_kws=None, ax=None)
```
Plot the residuals of a linear regression.
绘制线性回归的残差。
此函数将在x上回归y(可能作为鲁棒或多项式回归),然后绘制残差的散点图。 你可以选择将局部加权回归散点平滑法(LOWESS)拟合到残差图,这有助于确定残差是否存在结构。
参数:`x`: 向量或字符串
> 预测变量数据中的数据或列名称。
`y`:向量或字符串
> 响应变量的数据中的数据或列名称。
`data`:DataFrame, 可选
> 如果 *x* 和 *y* 是列名,则指定使用的DataFrame
This function will regress y on x (possibly as a robust or polynomial regression) and then draw a scatterplot of the residuals. You can optionally fit a lowess smoother to the residual plot, which can help in determining if there is structure to the residuals.
`lowess`: 布尔值, 可选
| Parameters: | **x** : vector or string
> 将局部加权回归散点平滑法(LOWESS)应用到残差散点图中。
> Data or column name in &lt;cite&gt;data&lt;/cite&gt; for the predictor variable.
`{x, y}_partial`:矩阵或字符串,可选
**y** : vector or string
> 具有与x相同的第一维的矩阵或数据中的列名称。这些变量被视为有误的,并在绘制之前从x或y变量中删除。
> Data or column name in &lt;cite&gt;data&lt;/cite&gt; for the response variable.
`order`:整数,可选
**data** : DataFrame, optional
> 计算残差时拟合多项式的阶数。
> DataFrame to use if &lt;cite&gt;x&lt;/cite&gt; and &lt;cite&gt;y&lt;/cite&gt; are column names.
`robust`:布尔值,可选
**lowess** : boolean, optional
> 在计算残差时拟合稳健的线性回归。
> Fit a lowess smoother to the residual scatterplot.
`dropna`:布尔值,可选
**{x, y}_partial** : matrix or string(s) , optional
> 如果为True,则在拟合和绘图时忽略缺少的数据。
> Matrix with same first dimension as &lt;cite&gt;x&lt;/cite&gt;, or column name(s) in &lt;cite&gt;data&lt;/cite&gt;. These variables are treated as confounding and are removed from the &lt;cite&gt;x&lt;/cite&gt; or &lt;cite&gt;y&lt;/cite&gt; variables before plotting.
`label`:字符串,可选
**order** : int, optional
> 将在任何图的图例中使用的标签。
> Order of the polynomial to fit when calculating the residuals.
`color`:matplotlib 颜色,可选
**robust** : boolean, optional
> 用于绘图的所有元素的颜色。
> Fit a robust linear regression when calculating the residuals.
`{scatter, line}_kws`: 字典,可选
**dropna** : boolean, optional
> 用于绘制图像的组件而传递给 scatter() 和 plot() 的其他关键字参数。
> If True, ignore observations with missing data when fitting and plotting.
`ax`:matplotlib轴,可选
**label** : string, optional
> 绘制到指定轴对象,否则在当前轴对象上绘图,如果轴不存在则创建一个新轴。
> Label that will be used in any plot legends.
**color** : matplotlib color, optional
返回值:ax:matplotlib Axes对象
> Color to use for all elements of the plot.
> 带有回归图像的轴对象
**{scatter, line}_kws** : dictionaries, optional
> Additional keyword arguments passed to scatter() and plot() for drawing the components of the plot.
**ax** : matplotlib axis, optional
也可以看看
> Plot into this axis, otherwise grab the current axis or make a new one if not existing.
[`regplot`](http://seaborn.pydata.org/generated/seaborn.regplot.html#seaborn.regplot)
|
| --- | --- |
| Returns: | ax: matplotlib axes
> Axes with the regression plot.
|
| --- | --- |
绘制一个简单的线性回归模型
See also
[`jointplot`](http://seaborn.pydata.org/generated/seaborn.jointplot.html#seaborn.jointplot)
Plot a simple linear regression model.marginal distrbutions.
\ No newline at end of file
边际分布。
\ No newline at end of file
# seaborn.heatmap
> 译者:[hyuuo](https://github.com/hyuuo)
```py
seaborn.heatmap(data, vmin=None, vmax=None, cmap=None, center=None, robust=False, annot=None, fmt='.2g', annot_kws=None, linewidths=0, linecolor='white', cbar=True, cbar_kws=None, cbar_ax=None, square=False, xticklabels='auto', yticklabels='auto', mask=None, ax=None, **kwargs)
```
Plot rectangular data as a color-encoded matrix.
将矩形数据绘制为颜色编码矩阵。
This is an Axes-level function and will draw the heatmap into the currently-active Axes if none is provided to the `ax` argument. Part of this Axes space will be taken and used to plot a colormap, unless `cbar` is False or a separate Axes is provided to `cbar_ax`.
这是一个坐标轴级的函数,如果没有提供给`ax`参数,它会将热力图绘制到当前活动的轴中。除非`cbar`为False或为`cbar_ax`提供单独的Axes,否则将使用此轴空间的一部分绘制颜色图。
| Parameters: | **data** : rectangular dataset
参数:`data`:矩形数据集
> 2D dataset that can be coerced into an ndarray. If a Pandas DataFrame is provided, the index/column information will be used to label the columns and rows.
> 可以强制转换为ndarray格式数据的2维数据集。如果提供了Pandas DataFrame数据,索引/列信息将用于标记列和行。
**vmin, vmax** : floats, optional
`vmin, vmax`:浮点型数据,可选参数。
> Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
> 用于锚定色彩映射的值,否则它们是从数据和其他关键字参数推断出来的。
**cmap** : matplotlib colormap name or object, or list of colors, optional
`cmap`:matplotlib 颜色条名称或者对象,或者是颜色列表,可选参数。
> The mapping from data values to color space. If not provided, the default will depend on whether `center` is set.
> 从数据值到颜色空间的映射。 如果没有提供,默认值将取决于是否设置了“center”。
**center** : float, optional
`center`:浮点数,可选参数。
> The value at which to center the colormap when plotting divergant data. Using this parameter will change the default `cmap` if none is specified.
> 绘制有色数据时将色彩映射居中的值。 如果没有指定,则使用此参数将更改默认的`cmap`。
**robust** : bool, optional
`robust`:布尔值,可选参数。
> If True and `vmin` or `vmax` are absent, the colormap range is computed with robust quantiles instead of the extreme values.
> 如果是True,并且`vmin`或`vmax`为空,则使用稳健分位数而不是极值来计算色彩映射范围。
**annot** : bool or rectangular dataset, optional
`annot`:布尔值或者矩形数据,可选参数。
> If True, write the data value in each cell. If an array-like with the same shape as `data`, then use this to annotate the heatmap instead of the raw data.
> 如果为True,则在每个热力图单元格中写入数据值。 如果数组的形状与`data`相同,则使用它来代替原始数据注释热力图。
**fmt** : string, optional
`fmt`:字符串,可选参数。
> String formatting code to use when adding annotations.
> 添加注释时要使用的字符串格式代码。
**annot_kws** : dict of key, value mappings, optional
`annot_kws`:字典或者键值对,可选参数。
> Keyword arguments for `ax.text` when `annot` is True.
> 当`annot`为True时,`ax.text`的关键字参数。
**linewidths** : float, optional
`linewidths`:浮点数,可选参数。
> Width of the lines that will divide each cell.
> 划分每个单元格的行的宽度。
**linecolor** : color, optional
`linecolor`:颜色,可选参数
> Color of the lines that will divide each cell.
> 划分每个单元的线条的颜色。
**cbar** : boolean, optional
`cbar`:布尔值,可选参数。
> Whether to draw a colorbar.
> 描述是否绘制颜色条。
**cbar_kws** : dict of key, value mappings, optional
`cbar_kws`:字典或者键值对,可选参数。
> Keyword arguments for &lt;cite&gt;fig.colorbar&lt;/cite&gt;.
> *fig.colorbar*的关键字参数。
**cbar_ax** : matplotlib Axes, optional
`cbar_ax`:matplotlib Axes,可选参数。
> Axes in which to draw the colorbar, otherwise take space from the main Axes.
> 用于绘制颜色条的轴,否则从主轴获取。
**square** : boolean, optional
`square`:布尔值,可选参数。
> If True, set the Axes aspect to “equal” so each cell will be square-shaped.
> 如果为True,则将坐标轴方向设置为“equal”,以使每个单元格为方形。
**xticklabels, yticklabels** : “auto”, bool, list-like, or int, optional
`xticklabels, yticklabels`:“auto”,布尔值,类列表值,或者整形数值,可选参数。
> If True, plot the column names of the dataframe. If False, don’t plot the column names. If list-like, plot these alternate labels as the xticklabels. If an integer, use the column names but plot only every n label. If “auto”, try to densely plot non-overlapping labels.
> 如果为True,则绘制数据框的列名称。如果为False,则不绘制列名称。如果是列表,则将这些替代标签绘制为xticklabels。如果是整数,则使用列名称,但仅绘制每个n标签。如果是“auto”,将尝试密集绘制不重叠的标签。
**mask** : boolean array or DataFrame, optional
`mask`:布尔数组或者DataFrame数据,可选参数。
> If passed, data will not be shown in cells where `mask` is True. Cells with missing values are automatically masked.
> 如果为空值,数据将不会显示在`mask`为True的单元格中。 具有缺失值的单元格将自动被屏蔽。
**ax** : matplotlib Axes, optional
`ax`:matplotlib Axes,可选参数。
> Axes in which to draw the plot, otherwise use the currently-active Axes.
> 绘制图的坐标轴,否则使用当前活动的坐标轴。
**kwargs** : other keyword arguments
`kwargs`:其他关键字参数。
> All other keyword arguments are passed to `ax.pcolormesh`.
> 所有其他关键字参数都传递给`ax.pcolormesh`。
|
| --- | --- |
| Returns: | **ax** : matplotlib Axes
返回值:`ax`:matplotlib Axes
> Axes object with the heatmap.
> 热力图的轴对象。
|
| --- | --- |
**另请参见**
See also
[`clustermap`](seaborn.clustermap.html#seaborn.clustermap "seaborn.clustermap")
Plot a matrix using hierachical clustering to arrange the rows and columns.
使用分层聚类绘制矩阵以排列行和列。
Examples
范例
Plot a heatmap for a numpy array:
为numpy数组绘制热力图:
```py
>>> import numpy as np; np.random.seed(0)
......@@ -107,7 +106,7 @@ Plot a heatmap for a numpy array:
![http://seaborn.pydata.org/_images/seaborn-heatmap-1.png](img/2dcc622657bb409719bb9c747e0456c4.jpg)
Change the limits of the colormap:
更改默认的colormap范围:
```py
>>> ax = sns.heatmap(uniform_data, vmin=0, vmax=1)
......@@ -116,7 +115,7 @@ Change the limits of the colormap:
![http://seaborn.pydata.org/_images/seaborn-heatmap-2.png](img/6600f3e11ba368f49ec94d562dd39b4a.jpg)
Plot a heatmap for data centered on 0 with a diverging colormap:
使用发散色图绘制以0为中心的数据的热力图:
```py
>>> normal_data = np.random.randn(10, 12)
......@@ -126,7 +125,7 @@ Plot a heatmap for data centered on 0 with a diverging colormap:
![http://seaborn.pydata.org/_images/seaborn-heatmap-3.png](img/519a9ac2d3daa6dd6160e4f71bf0e342.jpg)
Plot a dataframe with meaningful row and column labels:
使用特定的行和列标签绘制dataframe:
```py
>>> flights = sns.load_dataset("flights")
......@@ -137,7 +136,7 @@ Plot a dataframe with meaningful row and column labels:
![http://seaborn.pydata.org/_images/seaborn-heatmap-4.png](img/dd89a846e99f54ceffc01f58b1545cc1.jpg)
Annotate each cell with the numeric value using integer formatting:
使用整数格式的数字值注释每个小单元格:
```py
>>> ax = sns.heatmap(flights, annot=True, fmt="d")
......@@ -146,7 +145,7 @@ Annotate each cell with the numeric value using integer formatting:
![http://seaborn.pydata.org/_images/seaborn-heatmap-5.png](img/e28bcf9d1f72aedbb18ec128da502f35.jpg)
Add lines between each cell:
在每个单元格之间添加线:
```py
>>> ax = sns.heatmap(flights, linewidths=.5)
......@@ -155,7 +154,7 @@ Add lines between each cell:
![http://seaborn.pydata.org/_images/seaborn-heatmap-6.png](img/970cf8333ec7a6b8eec115254ad34265.jpg)
Use a different colormap:
使用不同的colormap:
```py
>>> ax = sns.heatmap(flights, cmap="YlGnBu")
......@@ -164,7 +163,7 @@ Use a different colormap:
![http://seaborn.pydata.org/_images/seaborn-heatmap-7.png](img/e18cb02ed3ad1b91b540951f2912539b.jpg)
Center the colormap at a specific value:
将colormap置于特定值的中心:
```py
>>> ax = sns.heatmap(flights, center=flights.loc["January", 1955])
......@@ -173,7 +172,7 @@ Center the colormap at a specific value:
![http://seaborn.pydata.org/_images/seaborn-heatmap-8.png](img/cf3d8b2d64f574209d01cfe330f3927b.jpg)
Plot every other column label and don’t plot row labels:
绘制每个其他列标签,而不绘制行标签:
```py
>>> data = np.random.randn(50, 20)
......@@ -183,7 +182,7 @@ Plot every other column label and don’t plot row labels:
![http://seaborn.pydata.org/_images/seaborn-heatmap-9.png](img/a3dadd3fc0e3dcd7aba22164979fb558.jpg)
Don’t draw a colorbar:
不绘制颜色条:
```py
>>> ax = sns.heatmap(flights, cbar=False)
......@@ -192,7 +191,7 @@ Don’t draw a colorbar:
![http://seaborn.pydata.org/_images/seaborn-heatmap-10.png](img/be698c1c447b1398ee3d4501aef2415c.jpg)
Use different axes for the colorbar:
在不同的坐标轴方向绘制颜色条:
```py
>>> grid_kws = {"height_ratios": (.9, .05), "hspace": .3}
......@@ -205,7 +204,7 @@ Use different axes for the colorbar:
![http://seaborn.pydata.org/_images/seaborn-heatmap-11.png](img/be6577fc41adf407960f66d71436521f.jpg)
Use a mask to plot only part of a matrix
使用遮罩绘制矩阵中的一部分
```py
>>> corr = np.corrcoef(np.random.randn(10, 200))
......@@ -216,4 +215,4 @@ Use a mask to plot only part of a matrix
```
![http://seaborn.pydata.org/_images/seaborn-heatmap-12.png](img/f683b3bba7ec2d231b917ed55aa858d1.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-heatmap-12.png](img/f683b3bba7ec2d231b917ed55aa858d1.jpg)
......@@ -6,27 +6,27 @@ seaborn.clustermap(data, pivot_kws=None, method='average', metric='euclidean', z
Plot a matrix dataset as a hierarchically-clustered heatmap.
| Parameters: | **data: 2D array-like**
参数:**data:2D array-like**
> Rectangular data for clustering. Cannot contain NAs.
**pivot_kws** : dict, optional
`pivot_kws`dict, optional
> If &lt;cite&gt;data&lt;/cite&gt; is a tidy dataframe, can provide keyword arguments for pivot to create a rectangular dataframe.
**method** : str, optional
`method`str, optional
> Linkage method to use for calculating clusters. See scipy.cluster.hierarchy.linkage documentation for more information: [https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.linkage.html)
**metric** : str, optional
`metric`str, optional
> Distance metric to use for the data. See scipy.spatial.distance.pdist documentation for more options [https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html](https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html) To use different metrics (or methods) for rows and columns, you may construct each linkage matrix yourself and provide them as {row,col}_linkage.
**z_score** : int or None, optional
`z_score`int or None, optional
> Either 0 (rows) or 1 (columns). Whether or not to calculate z-scores for the rows or the columns. Z scores are: z = (x - mean)/std, so values in each row (column) will get the mean of the row (column) subtracted, then divided by the standard deviation of the row (column). This ensures that each row (column) has mean of 0 and variance of 1.
**standard_scale** : int or None, optional
`standard_scale`int or None, optional
> Either 0 (rows) or 1 (columns). Whether or not to standardize that dimension, meaning for each row or column, subtract the minimum and divide each by its maximum.
......@@ -34,38 +34,36 @@ Plot a matrix dataset as a hierarchically-clustered heatmap.
> Size of the figure to create.
**cbar_kws** : dict, optional
`cbar_kws`dict, optional
> Keyword arguments to pass to `cbar_kws` in `heatmap`, e.g. to add a label to the colorbar.
**{row,col}_cluster** : bool, optional
`{row,col}_cluster`bool, optional
> If True, cluster the {rows, columns}.
**{row,col}_linkage** : numpy.array, optional
`{row,col}_linkage`numpy.array, optional
> Precomputed linkage matrix for the rows or columns. See scipy.cluster.hierarchy.linkage for specific formats.
**{row,col}_colors** : list-like or pandas DataFrame/Series, optional
`{row,col}_colors`list-like or pandas DataFrame/Series, optional
> List of colors to label for either the rows or columns. Useful to evaluate whether samples within a group are clustered together. Can use nested lists or DataFrame for multiple color levels of labeling. If given as a DataFrame or Series, labels for the colors are extracted from the DataFrames column names or from the name of the Series. DataFrame/Series colors are also matched to the data by their index, ensuring colors are drawn in the correct order.
**mask** : boolean array or DataFrame, optional
`mask`boolean array or DataFrame, optional
> If passed, data will not be shown in cells where `mask` is True. Cells with missing values are automatically masked. Only used for visualizing, not for calculating.
**kwargs** : other keyword arguments
`kwargs`other keyword arguments
> All other keyword arguments are passed to `sns.heatmap`
|
| --- | --- |
| Returns: | **clustergrid** : ClusterGrid
返回值:`clustergrid`:ClusterGrid
> A ClusterGrid instance.
|
| --- | --- |
Notes
......
# seaborn.FacetGrid
> 译者:[hyuuo](https://github.com/hyuuo)
```py
class seaborn.FacetGrid(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=True, height=3, aspect=1, palette=None, row_order=None, col_order=None, hue_order=None, hue_kws=None, dropna=True, legend_out=True, despine=True, margin_titles=False, xlim=None, ylim=None, subplot_kws=None, gridspec_kws=None, size=None)
```
Multi-plot grid for plotting conditional relationships.
用于绘制条件关系的多图网格。
```py
__init__(data, row=None, col=None, hue=None, col_wrap=None, sharex=True, sharey=True, height=3, aspect=1, palette=None, row_order=None, col_order=None, hue_order=None, hue_kws=None, dropna=True, legend_out=True, despine=True, margin_titles=False, xlim=None, ylim=None, subplot_kws=None, gridspec_kws=None, size=None)
```
Initialize the matplotlib figure and FacetGrid object.
初始化matplotlib画布和FacetGrid对象。
该类将数据集映射到由行和列组成的网格中的多个轴上,这些轴与数据集中变量的级别对应。它产生的图通常被称为“lattice”,“trellis”或“small-multiple”图形。
它还可以用`hue`参数表示第三个变量的级别,该参数绘制不同颜色的不同数据子集。它使用颜色来解析第三维度上的元素,但是只绘制相互重叠的子集,并且不会像接受“hue”的坐标轴级函数那样为特定的可视化定制“hue”参数。
当使用从数据集推断语义映射的seaborn函数时,必须注意在各个方面之间同步这些映射。在大多数情况下,使用图形级函数(例如[`relplot()`](seaborn.relplot.html#seaborn.relplot "seaborn.relplot")[`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot"))比直接使用[`FacetGrid`](seaborn.FacetGrid.html#seaborn.FacetGrid "seaborn.FacetGrid")更好。
基本工作流程是使用数据集和用于构造网格的变量初始化FacetGrid对象。然后,通过调用[`FacetGrid.map()`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")[`FacetGrid.map_dataframe()`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe"),可以将一个或多个绘图函数应用于每个子集。最后,可以使用其他方法调整绘图,以执行更改轴标签、使用不同刻度或添加图例等操作。有关详细信息,请参阅下面的详细代码示例。
更多相关信息请参阅[`教程`](../tutorial/axis_grids.html#grid-tutorial)
This class maps a dataset onto multiple axes arrayed in a grid of rows and columns that correspond to _levels_ of variables in the dataset. The plots it produces are often called “lattice”, “trellis”, or “small-multiple” graphics.
参数:`data`:DataFrame数据。
It can also represent levels of a third varaible with the `hue` parameter, which plots different subets of data in different colors. This uses color to resolve elements on a third dimension, but only draws subsets on top of each other and will not tailor the `hue` parameter for the specific visualization the way that axes-level functions that accept `hue` will.
> 整洁的(“长形式”)dataframe数据,其中每一列是一个变量,每一行是一个观察实例。
When using seaborn functions that infer semantic mappings from a dataset, care must be taken to synchronize those mappings across facets. In most cases, it will be better to use a figure-level function (e.g. [`relplot()`](seaborn.relplot.html#seaborn.relplot "seaborn.relplot") or [`catplot()`](seaborn.catplot.html#seaborn.catplot "seaborn.catplot")) than to use [`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid") directly.
`row, col, hue`:字符串。
The basic workflow is to initialize the [`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid") object with the dataset and the variables that are used to structure the grid. Then one or more plotting functions can be applied to each subset by calling [`FacetGrid.map()`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map") or [`FacetGrid.map_dataframe()`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe"). Finally, the plot can be tweaked with other methods to do things like change the axis labels, use different ticks, or add a legend. See the detailed code examples below for more information.
> 定义数据子集的变量,这些变量将在网格的不同方面绘制。请参阅`*_order`参数以控制此变量的级别顺序。
See the [tutorial](../tutorial/axis_grids.html#grid-tutorial) for more information.
`col_wrap`:整形数值,可选参数。
| Parameters: | **data** : DataFrame
> 以此参数值来限制网格的列维度,以便列面跨越多行。与`row`面不兼容。
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
`share{x,y}`:布尔值,'col' 或 'row'可选
**row, col, hue** : strings
> 如果为true,则跨列共享y轴或者跨行共享x轴。
> Variables that define subsets of the data, which will be drawn on separate facets in the grid. See the `*_order` parameters to control the order of levels of this variable.
`height`:标量,可选参数。
**col_wrap** : int, optional
> 每个图片的高度设定(以英寸为单位)。另见:*aspect*
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
`aspect`:标量,可选参数。
**share{x,y}** : bool, ‘col’, or ‘row’ optional
> 每个图片的纵横比,因此aspect * height给出每个图片的宽度,单位为英寸。
> If true, the facets will share y axes across columns and/or x axes across rows.
`palette`:调色板名称,列表或字典,可选参数。
**height** : scalar, optional
> 用于色调变量的不同级别的颜色。应为[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的参数,或者是将色调级别映射到matplotlib颜色的字典。
> Height (in inches) of each facet. See also: `aspect`.
`{row,col,hue}_order`:列表,可选参数。
**aspect** : scalar, optional
> 对所给命令级别进行排序。默认情况下,这将是在数据中显示的级别,或者,如果变量是pandas分类,则为类别顺序。
> Aspect ratio of each facet, so that `aspect * height` gives the width of each facet in inches.
`hue_kws`:参数-列表值的映射字典
**palette** : palette name, list, or dict, optional
> 插入到绘图调用中的其他关键字参数,使得其他绘图属性在色调变量的级别上有所不同(例如散点图中的标记)。
> Colors to use for the different levels of the `hue` variable. Should be something that can be interpreted by [`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette"), or a dictionary mapping hue levels to matplotlib colors.
`legend_out`:布尔值,可选参数。
**{row,col,hue}_order** : lists, optional
> 如果为True,则图形尺寸将被扩展,图例将绘制在中间右侧的图形之外。
> Order for the levels of the faceting variables. By default, this will be the order that the levels appear in `data` or, if the variables are pandas categoricals, the category order.
`despine`:布尔值,可选参数。
**hue_kws** : dictionary of param -&gt; list of values mapping
> 从图中移除顶部和右侧边缘框架。
> Other keyword arguments to insert into the plotting call to let other plot attributes vary across levels of the hue variable (e.g. the markers in a scatterplot).
`margin_titles`:布尔值,可选参数。
**legend_out** : bool, optional
> 如果为True,则行变量的标题将绘制在最后一列的右侧。此选项是实验性的,可能无法在所有情况下使用。
> If `True`, the figure size will be extended, and the legend will be drawn outside the plot on the center right.
`{x, y}lim`:元组,可选参数。
**despine** : boolean, optional
> 每个图片上每个轴的限制(仅当share {x,y}为True时才相关)。
> Remove the top and right spines from the plots.
`subplot_kws`:字典,可选参数。
**margin_titles** : bool, optional
> 传递给matplotlib subplot(s)方法的关键字参数字典。
> If `True`, the titles for the row variable are drawn to the right of the last column. This option is experimental and may not work in all cases.
`gridspec_kws`:字典,可选参数。
**{x, y}lim: tuples, optional**
> 传递给matplotlib的`gridspec`模块(通过`plt.subplots`)的关键字参数字典。需要matplotlib> = 1.4,如果`col_wrap`不是`None`,则忽略它。
> Limits for each of the axes on each facet (only relevant when share{x, y} is True.
**另请参见**
**subplot_kws** : dict, optional
用于绘制成对关系的子图网格。
> Dictionary of keyword arguments passed to matplotlib subplot(s) methods.
[`relplot`](#seaborn.relplot "seaborn.relplot")
**gridspec_kws** : dict, optional
结合关系图和[`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid")
> Dictionary of keyword arguments passed to matplotlib’s `gridspec` module (via `plt.subplots`). Requires matplotlib &gt;= 1.4 and is ignored if `col_wrap` is not `None`.
[`catplot`](#seaborn.catplot "seaborn.catplot")
|
| --- | --- |
结合分类图和[`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid")
See also
[`lmplot`](#seaborn.lmplot "seaborn.lmplot")
Subplot grid for plotting pairwise relationships.Combine a relational plot and a [`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid").Combine a categorical plot and a [`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid").Combine a regression plot and a [`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid").
结合回归图和[`FacetGrid`](#seaborn.FacetGrid "seaborn.FacetGrid")
Examples
范例
Initialize a 2x2 grid of facets using the tips dataset:
使用tips数据集初始化2x2网格图:
```py
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
......@@ -102,7 +113,7 @@ Initialize a 2x2 grid of facets using the tips dataset:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-1.png](img/b8699392ad92687d3ac264d00b00ec9b.jpg)
Draw a univariate plot on each facet:
在每个子图绘制一个单变量图:
```py
>>> import matplotlib.pyplot as plt
......@@ -113,9 +124,9 @@ Draw a univariate plot on each facet:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-2.png](img/ee99e47d6e0d2262037bca2e7fdb9772.jpg)
(Note that it’s not necessary to re-catch the returned variable; it’s the same object, but doing so in the examples makes dealing with the doctests somewhat less annoying).
(注意,没有必要重新捕获返回的变量;它是相同的对象,但在示例中这样做使得处理doctests更加方便)。
Pass additional keyword arguments to the mapped function:
将其他关键字参数传递给映射函数:
```py
>>> import numpy as np
......@@ -127,7 +138,7 @@ Pass additional keyword arguments to the mapped function:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-3.png](img/7bd763d402e774603d6f5e7c48c2369a.jpg)
Plot a bivariate function on each facet:
在每个子图绘制一个双变量函数:
```py
>>> g = sns.FacetGrid(tips, col="time", row="smoker")
......@@ -137,7 +148,7 @@ Plot a bivariate function on each facet:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-4.png](img/2aca4924009e92a55bc1579fc086d36c.jpg)
Assign one of the variables to the color of the plot elements:
将其中一个变量分配给绘图元素的颜色:
```py
>>> g = sns.FacetGrid(tips, col="time", hue="smoker")
......@@ -148,7 +159,7 @@ Assign one of the variables to the color of the plot elements:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-5.png](img/c53a49f5b838d50776627fc8910138ce.jpg)
Change the height and aspect ratio of each facet:
更改每个子图的高度和纵横比:
```py
>>> g = sns.FacetGrid(tips, col="day", height=4, aspect=.5)
......@@ -158,7 +169,7 @@ Change the height and aspect ratio of each facet:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-6.png](img/ca19289fa3db7f35bf27fa3f09db128e.jpg)
Specify the order for plot elements:
指定绘图元素的顺序:
```py
>>> g = sns.FacetGrid(tips, col="smoker", col_order=["Yes", "No"])
......@@ -168,7 +179,7 @@ Specify the order for plot elements:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-7.png](img/d84004bd86dc3645488324a3fbb3b060.jpg)
Use a different color palette:
使用不同的调色板:
```py
>>> kws = dict(s=50, linewidth=.5, edgecolor="w")
......@@ -181,7 +192,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-8.png](img/fe9b97ad8c3e66c3a2514249fcd62ee6.jpg)
Use a dictionary mapping hue levels to colors:
使用字典将色调级别映射到颜色:
```py
>>> pal = dict(Lunch="seagreen", Dinner="gray")
......@@ -194,7 +205,7 @@ Use a dictionary mapping hue levels to colors:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-9.png](img/9299602c8a3b49e2a9095ad9ea69f07f.jpg)
Additionally use a different marker for the hue levels:
另外,为色调级别使用不同的标记:
```py
>>> g = sns.FacetGrid(tips, col="sex", hue="time", palette=pal,
......@@ -207,7 +218,7 @@ Additionally use a different marker for the hue levels:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-10.png](img/92494d907a4bd738426ff755349e4992.jpg)
“Wrap” a column variable with many levels into the rows:
将包含多个级别的列变量“换行”到行中:
```py
>>> att = sns.load_dataset("attention")
......@@ -218,7 +229,7 @@ Additionally use a different marker for the hue levels:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-11.png](img/3a3de5e84041d929dbf5cbade67f93e6.jpg)
Define a custom bivariate function to map onto the grid:
定义一个自定义双变量函数来映射到网格:
```py
>>> from scipy import stats
......@@ -234,7 +245,7 @@ Define a custom bivariate function to map onto the grid:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-12.png](img/a84563a49e5578ddeff33795280887f1.jpg)
Define a custom function that uses a `DataFrame` object and accepts column names as positional variables:
定义一个使用`DataFrame`对象的自定义函数,并接受列名作为位置变量:
```py
>>> import pandas as pd
......@@ -255,7 +266,7 @@ Define a custom function that uses a `DataFrame` object and accepts column names
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-13.png](img/2017a8a703bdcc077baea030a758721d.jpg)
Use different axes labels after plotting:
绘图后使用不同的轴标签:
```py
>>> g = sns.FacetGrid(tips, col="smoker", row="sex")
......@@ -266,7 +277,7 @@ Use different axes labels after plotting:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-14.png](img/52d5efab2c08ec72873b3e66fea66d14.jpg)
Set other attributes that are shared across the facetes:
设置每个子图共享的其他属性:
```py
>>> g = sns.FacetGrid(tips, col="smoker", row="sex")
......@@ -278,7 +289,7 @@ Set other attributes that are shared across the facetes:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-15.png](img/308a2f3dd32f77b25254d6650cce7be8.jpg)
Use a different template for the facet titles:
为子图标题使用不同的模板:
```py
>>> g = sns.FacetGrid(tips, col="size", col_wrap=3)
......@@ -289,7 +300,7 @@ Use a different template for the facet titles:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-16.png](img/b68bba1b9871f75b818870d08a9e3523.jpg)
Tighten the facets:
收紧每个子图:
```py
>>> g = sns.FacetGrid(tips, col="smoker", row="sex",
......@@ -303,24 +314,38 @@ Tighten the facets:
![http://seaborn.pydata.org/_images/seaborn-FacetGrid-17.png](img/30bd1c7aa657fabb90851a094c8d0a1e.jpg)
Methods
| [`__init__`](#seaborn.FacetGrid.__init__ "seaborn.FacetGrid.__init__")(data[, row, col, hue, col_wrap, …]) | Initialize the matplotlib figure and FacetGrid object. |
| `add_legend`([legend_data, title, label_order]) | Draw a legend, maybe placing it outside axes and resizing the figure. |
| `despine`(**kwargs) | Remove axis spines from the facets. |
| `facet_axis`(row_i, col_j) | Make the axis identified by these indices active and return it. |
| `facet_data`() | Generator for name indices and data subsets for each facet. |
| [`map`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")(func, *args, **kwargs) | Apply a plotting function to each facet’s subset of the data. |
| [`map_dataframe`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe")(func, *args, **kwargs) | Like `.map` but passes args as strings and inserts data in kwargs. |
| `savefig`(*args, **kwargs) | Save the figure. |
| `set`(**kwargs) | Set attributes on each subplot Axes. |
| `set_axis_labels`([x_var, y_var]) | Set axis labels on the left column and bottom row of the grid. |
| `set_titles`([template, row_template, …]) | Draw titles either above each facet or on the grid margins. |
| `set_xlabels`([label]) | Label the x axis on the bottom row of the grid. |
| `set_xticklabels`([labels, step]) | Set x axis tick labels on the bottom row of the grid. |
| `set_ylabels`([label]) | Label the y axis on the left column of the grid. |
| `set_yticklabels`([labels]) | Set y axis tick labels on the left column of the grid. |
Attributes
| `ax` | Easy access to single axes. |
\ No newline at end of file
方法
| [`__init__`](#seaborn.FacetGrid.__init__ "seaborn.FacetGrid.__init__")(data[, row, col, hue, col_wrap, …]) | 初始化matplotlib画布和FacetGrid对象。 |
| `add_legend`([legend_data, title, label_order]) | 绘制一个图例,可能将其放在轴外并调整图形大小。|
| `despine`(\**kwargs) | 从子图中移除轴的边缘框架。 |
| `facet_axis`(row_i, col_j) | 使这些索引识别的轴处于活动状态并返回。 |
| `facet_data`() | 用于每个子图的名称索引和数据子集的生成器。 |
| [`map`](seaborn.FacetGrid.map.html#seaborn.FacetGrid.map "seaborn.FacetGrid.map")(func, *args, \**kwargs) | 将绘图功能应用于每个子图的数据子集。 |
| [`map_dataframe`](seaborn.FacetGrid.map_dataframe.html#seaborn.FacetGrid.map_dataframe "seaborn.FacetGrid.map_dataframe")(func, *args, \**kwargs) | 像`.map`一样,但是将args作为字符串传递并在kwargs中插入数据。 |
| `savefig`(*args, \**kwargs) | 保存图片。 |
| `set`(\**kwargs) | 在每个子图集坐标轴上设置属性。|
| `set_axis_labels`([x_var, y_var]) | 在网格的左列和底行设置轴标签。 |
| `set_titles`([template, row_template, …]) | 在每个子图上方或网格边缘绘制标题。 |
| `set_xlabels`([label]) | 在网格的底行标记x轴。 |
| `set_xticklabels`([labels, step]) | 在网格的底行设置x轴刻度标签。 |
| `set_ylabels`([label]) | 在网格的左列标记y轴。 |
| `set_yticklabels`([labels]) | 在网格的左列上设置y轴刻度标签。 |
属性
| `ax` | 轻松访问单个坐标轴。 |
\ No newline at end of file
# seaborn.FacetGrid.map
> 译者:[sfw134](https://github.com/sfw134)
```py
FacetGrid.map(func, *args, **kwargs)
```
Apply a plotting function to each facet’s subset of the data.
将绘图函数应用于每个方面的数据子集。
参数:`func`:可调用
| Parameters: | **func** : callable
> 一个接受数据和关键字参数的绘图函数。它必须绘制到当前活动的matplotlib轴并采用&lt;cite&gt;color&lt;/cite&gt;关键字参数。如果在&lt;cite&gt;hue&lt;/cite&gt;维度上进行分面,必须也使用&lt;cite&gt;label&lt;/cite&gt;关键字参数。
> A plotting function that takes data and keyword arguments. It must plot to the currently active matplotlib Axes and take a &lt;cite&gt;color&lt;/cite&gt; keyword argument. If faceting on the &lt;cite&gt;hue&lt;/cite&gt; dimension, it must also take a &lt;cite&gt;label&lt;/cite&gt; keyword argument.
`args`:字符串
**args** : strings
> 数据的列名,用于标识要绘制数据的变量。每个变量的数据按照调用中指定变量的顺序传递给&lt;cite&gt;func&lt;/cite&gt;。
> Column names in self.data that identify variables with data to plot. The data for each variable is passed to &lt;cite&gt;func&lt;/cite&gt; in the order the variables are specified in the call.
`kwargs`:关键字参数
**kwargs** : keyword arguments
> 所有的关键字参数都被传递给绘图函数。
> All keyword arguments are passed to the plotting function.
|
| --- | --- |
| Returns: | **self** : object
返回值:`self`:对象
> Returns self.
> 返回自身。
|
| --- | --- |
\ No newline at end of file
# seaborn.FacetGrid.map_dataframe
> 译者:[sfw134](https://github.com/sfw134)
```py
FacetGrid.map_dataframe(func, *args, **kwargs)
```
Like `.map` but passes args as strings and inserts data in kwargs.
`.map`类似,但是将args作为字符串传递并将数据插入到kwargs中.
此方法适用于使用接受长格式DataFrame作为&lt;cite&gt;data&lt;/cite&gt;关键字参数并使用字符串变量名访问该DataFrame中的数据的函数进行绘图。
This method is suitable for plotting with functions that accept a long-form DataFrame as a &lt;cite&gt;data&lt;/cite&gt; keyword argument and access the data in that DataFrame using string variable names.
参数:`func`:可调用
| Parameters: | **func** : callable
> 一个接受数据和关键字参数的绘图函数。与&lt;cite&gt;map&lt;/cite&gt;方法不同,此处使用的函数必须“理解”Pandas对象。它也必须绘制到当前活动的matpltolib轴并采用&lt;cite&gt;color&lt;/cite&gt;关键字参数。如果在<cite>hue</cite>维度上进行分面,必须也使用<cite>label</cite>关键字参数。
> A plotting function that takes data and keyword arguments. Unlike the &lt;cite&gt;map&lt;/cite&gt; method, a function used here must “understand” Pandas objects. It also must plot to the currently active matplotlib Axes and take a &lt;cite&gt;color&lt;/cite&gt; keyword argument. If faceting on the &lt;cite&gt;hue&lt;/cite&gt; dimension, it must also take a &lt;cite&gt;label&lt;/cite&gt; keyword argument.
`args`:字符串
**args** : strings
> 数据的列名,用于标识要绘制数据的变量。每个变量的数据按照调用中指定变量的顺序传递给<cite>func</cite>。
> Column names in self.data that identify variables with data to plot. The data for each variable is passed to &lt;cite&gt;func&lt;/cite&gt; in the order the variables are specified in the call.
`kwargs`:关键字参数
**kwargs** : keyword arguments
> 所有的关键字参数被传递给绘图函数。
> All keyword arguments are passed to the plotting function.
|
| --- | --- |
| Returns: | **self** : object
返回值:`self`:对象
> Returns self.
> 返回自身。
|
| --- | --- |
\ No newline at end of file
......@@ -4,74 +4,73 @@
class seaborn.PairGrid(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, height=2.5, aspect=1, despine=True, dropna=True, size=None)
```
Subplot grid for plotting pairwise relationships in a dataset.
用于绘制数据集中成对关系的子图网格。
This class maps each variable in a dataset onto a column and row in a grid of multiple axes. Different axes-level plotting functions can be used to draw bivariate plots in the upper and lower triangles, and the the marginal distribution of each variable can be shown on the diagonal.
此类将数据集中的每个变量映射到多个轴的网格中的列和行。可以使用不同的轴级绘图函数来绘制上三角和下三角的双变量图,并且对角线上可以显示每个变量的边际分布。
It can also represent an additional level of conditionalization with the `hue` parameter, which plots different subets of data in different colors. This uses color to resolve elements on a third dimension, but only draws subsets on top of each other and will not tailor the `hue` parameter for the specific visualization the way that axes-level functions that accept `hue` will.
它还可以通过`hue`参数用不同颜色绘制不同的数据子集来表示附加级别的条件化。这使用颜色来解析第三维的元素,但只是在彼此之上绘制子集,并且不会像接受`hue`的轴级函数那样为特定可视化定制`hue`参数。
See the [tutorial](../tutorial/axis_grids.html#grid-tutorial) for more information.
参考[教程](../tutorial/axis_grids.html#grid-tutorial)获取更多信息。
```py
__init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, height=2.5, aspect=1, despine=True, dropna=True, size=None)
```
Initialize the plot figure and PairGrid object.
初始化绘图和PairGrid对象。
| Parameters: | **data** : DataFrame
参数:`data`:DataFrame格式
> Tidy (long-form) dataframe where each column is a variable and each row is an observation.
> 整洁(长形式)数据框,其中每列是一个变量,每行是一个观察。
**hue** : string (variable name), optional
`hue`:字符串 (变量名), 可选
> Variable in `data` to map plot aspects to different colors.
> `data`中的变量,将绘图的不同面映射为不同的颜色。
**hue_order** : list of strings
`hue_order`:字符串列表
> Order for the levels of the hue variable in the palette
> 调色板中色调变量的等级顺序
**palette** : dict or seaborn color palette
`palette`:字典或者seaborn调色板
> Set of colors for mapping the `hue` variable. If a dict, keys should be values in the `hue` variable.
> 用于映射`hue`变量的颜色集.如果是一个字典,键应为`hue`变量中的值。
**hue_kws** : dictionary of param -&gt; list of values mapping
`hue_kws`:参数字典 -&gt; 值列表映射
> Other keyword arguments to insert into the plotting call to let other plot attributes vary across levels of the hue variable (e.g. the markers in a scatterplot).
> 其它的关键字参数,通过插入到绘图调用中使得其它的绘图属性在色调变量的不同水平上变化(例如散点图中的标记)。
**vars** : list of variable names, optional
`vars`:变量名列表, 可选
> Variables within `data` to use, otherwise use every column with a numeric datatype.
> 使用`data`中的变量,否则使用一个数值型数据类型的每一列。
**{x, y}_vars** : lists of variable names, optional
`{x, y}_vars`:变量名列表,可选
> Variables within `data` to use separately for the rows and columns of the figure; i.e. to make a non-square plot.
> 将`data`中的变量分别用于图的行和列,即制作非方形图。
**height** : scalar, optional
`height`:标量,可选
> Height (in inches) of each facet.
> 每个刻面的高度(以英寸为单位)。
**aspect** : scalar, optional
`aspect`:标量,可选
> Aspect * height gives the width (in inches) of each facet.
> aspect和height的乘积得出每个刻面的宽度(以英寸为单位)。
**despine** : boolean, optional
`despine`:布尔值,可选
> Remove the top and right spines from the plots.
> 从图中移除顶部和右侧脊柱。
**dropna** : boolean, optional
`dropna`:布尔值,可选
> Drop missing values from the data before plotting.
> 在绘图之前删除数据中的缺失值。
|
| --- | --- |
See also
Easily drawing common uses of [`PairGrid`](#seaborn.PairGrid "seaborn.PairGrid").Subplot grid for plotting conditional relationships.
另见
Examples
轻松绘制[`PairGrid`](#seaborn.PairGrid "seaborn.PairGrid")的常用用法。用于绘制条件关系的子图网格。
Draw a scatterplot for each pairwise relationship:
例子
为每个成对关系绘制一个散点图:
```py
>>> import matplotlib.pyplot as plt
......@@ -84,7 +83,7 @@ Draw a scatterplot for each pairwise relationship:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-1.png](img/34fc6de3cfc117757cc0e5f658a06928.jpg)
Show a univariate distribution on the diagonal:
在对角线上显示单变量分布:
```py
>>> g = sns.PairGrid(iris)
......@@ -95,9 +94,9 @@ Show a univariate distribution on the diagonal:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-2.png](img/7e2b84efc57efecba1f8c1bfad570874.jpg)
(It’s not actually necessary to catch the return value every time, as it is the same object, but it makes it easier to deal with the doctests).
(实际上没有必要每次都获取返回值,因为它是同一个对象,但它使得更容易处理文档测试)。
Color the points using a categorical variable:
使用分类变量对点进行着色:
```py
>>> g = sns.PairGrid(iris, hue="species")
......@@ -109,7 +108,7 @@ Color the points using a categorical variable:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-3.png](img/6df84055fcde05fec3e0b9794967ad71.jpg)
Use a different style to show multiple histograms:
使用不同的样式显示多个直方图:
```py
>>> g = sns.PairGrid(iris, hue="species")
......@@ -121,7 +120,7 @@ Use a different style to show multiple histograms:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-4.png](img/b269cdc188b02e86196c919d1bd87402.jpg)
Plot a subset of variables
绘制变量的子集
```py
>>> g = sns.PairGrid(iris, vars=["sepal_length", "sepal_width"])
......@@ -131,7 +130,7 @@ Plot a subset of variables
![http://seaborn.pydata.org/_images/seaborn-PairGrid-5.png](img/81ab9afd2faa6448de3c2b5a73ea3320.jpg)
Pass additional keyword arguments to the functions
将其它关键字参数传给函数。
```py
>>> g = sns.PairGrid(iris)
......@@ -142,7 +141,7 @@ Pass additional keyword arguments to the functions
![http://seaborn.pydata.org/_images/seaborn-PairGrid-6.png](img/ff58dc3588f11a9e3f9291926a0c86ff.jpg)
Use different variables for the rows and columns:
对行和列使用不同的变量:
```py
>>> g = sns.PairGrid(iris,
......@@ -154,7 +153,7 @@ Use different variables for the rows and columns:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-7.png](img/0d8364e9bb731fa5d89b998087ba0635.jpg)
Use different functions on the upper and lower triangles:
在上三角和下三角使用不同的函数:
```py
>>> g = sns.PairGrid(iris)
......@@ -166,7 +165,7 @@ Use different functions on the upper and lower triangles:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-8.png](img/58e8af844e6f097dc5995d7a2be70b0e.jpg)
Use different colors and markers for each categorical level:
为每个分类级别使用不同的颜色和标记:
```py
>>> g = sns.PairGrid(iris, hue="species", palette="Set2",
......@@ -178,14 +177,14 @@ Use different colors and markers for each categorical level:
![http://seaborn.pydata.org/_images/seaborn-PairGrid-9.png](img/c9a2068151affcefc99a7b280ab0a52b.jpg)
Methods
| [`__init__`](#seaborn.PairGrid.__init__ "seaborn.PairGrid.__init__")(data[, hue, hue_order, palette, …]) | Initialize the plot figure and PairGrid object. |
| `add_legend`([legend_data, title, label_order]) | Draw a legend, maybe placing it outside axes and resizing the figure. |
| [`map`](seaborn.PairGrid.map.html#seaborn.PairGrid.map "seaborn.PairGrid.map")(func, **kwargs) | Plot with the same function in every subplot. |
| [`map_diag`](seaborn.PairGrid.map_diag.html#seaborn.PairGrid.map_diag "seaborn.PairGrid.map_diag")(func, **kwargs) | Plot with a univariate function on each diagonal subplot. |
| [`map_lower`](seaborn.PairGrid.map_lower.html#seaborn.PairGrid.map_lower "seaborn.PairGrid.map_lower")(func, **kwargs) | Plot with a bivariate function on the lower diagonal subplots. |
| [`map_offdiag`](seaborn.PairGrid.map_offdiag.html#seaborn.PairGrid.map_offdiag "seaborn.PairGrid.map_offdiag")(func, **kwargs) | Plot with a bivariate function on the off-diagonal subplots. |
| [`map_upper`](seaborn.PairGrid.map_upper.html#seaborn.PairGrid.map_upper "seaborn.PairGrid.map_upper")(func, **kwargs) | Plot with a bivariate function on the upper diagonal subplots. |
| `savefig`(*args, **kwargs) | Save the figure. |
| `set`(**kwargs) | Set attributes on each subplot Axes. |
\ No newline at end of file
方法
| [`__init__`](#seaborn.PairGrid.__init__ "seaborn.PairGrid.__init__")(data[, hue, hue_order, palette, …]) | 初始化绘图和PairGrid对象。 |
| `add_legend`([legend_data, title, label_order]) | 绘制一个图例,可能将其放在轴外并调整图形大小。 |
| [`map`](seaborn.PairGrid.map.html#seaborn.PairGrid.map "seaborn.PairGrid.map")(func, **kwargs) | 在每一个子图上用相同的函数绘制。 |
| [`map_diag`](seaborn.PairGrid.map_diag.html#seaborn.PairGrid.map_diag "seaborn.PairGrid.map_diag")(func, **kwargs) | 在每个对角线子图上用一个单变量函数绘制。 |
| [`map_lower`](seaborn.PairGrid.map_lower.html#seaborn.PairGrid.map_lower "seaborn.PairGrid.map_lower")(func, **kwargs) | 在下三角子图上用一个双变量函数绘制。|
| [`map_offdiag`](seaborn.PairGrid.map_offdiag.html#seaborn.PairGrid.map_offdiag "seaborn.PairGrid.map_offdiag")(func, **kwargs) | 在非对角线子图上用一个双变量函数绘制。 |
| [`map_upper`](seaborn.PairGrid.map_upper.html#seaborn.PairGrid.map_upper "seaborn.PairGrid.map_upper")(func, **kwargs) | 在上三角子图上用一个双变量函数绘制。|
| `savefig`(*args, **kwargs) | 保存图。 |
| `set`(**kwargs) | 在每个子图轴上设置属性。 |
......@@ -4,11 +4,9 @@
PairGrid.map(func, **kwargs)
```
Plot with the same function in every subplot.
在每个子图中用相同的函数绘制。
| Parameters: | **func** : callable plotting function
参数:`func`:可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
|
| --- | --- |
\ No newline at end of file
......@@ -4,11 +4,9 @@
PairGrid.map_diag(func, **kwargs)
```
Plot with a univariate function on each diagonal subplot.
在每一个对角线子图上用一个单变量函数绘制。
| Parameters: | **func** : callable plotting function
参数:`func`:可调用的绘图函数
> Must take an x array as a positional argument and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
>必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
|
| --- | --- |
\ No newline at end of file
......@@ -4,11 +4,9 @@
PairGrid.map_offdiag(func, **kwargs)
```
Plot with a bivariate function on the off-diagonal subplots.
在非对角线子图上用一个双变量函数绘图。
| Parameters: | **func** : callable plotting function
参数:`func`:可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
|
| --- | --- |
\ No newline at end of file
......@@ -4,11 +4,9 @@
PairGrid.map_lower(func, **kwargs)
```
Plot with a bivariate function on the lower diagonal subplots.
在下对角线子图上用一个双变量函数绘图。
| Parameters: | **func** : callable plotting function
参数:`func`:可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为`color`和`label`的kwargs。
|
| --- | --- |
\ No newline at end of file
此差异已折叠。
......@@ -4,11 +4,9 @@
PairGrid.map_upper(func, **kwargs)
```
Plot with a bivariate function on the upper diagonal subplots.
在上对角线子图上用一个双变量函数绘图。
| Parameters: | **func** : callable plotting function
参数:`func`:可调用的绘图函数
> Must take x, y arrays as positional arguments and draw onto the “currently active” matplotlib Axes. Also needs to accept kwargs called `color` and `label`.
> 必须将x,y数组作为位置参数并绘制到“当前活动”的matplotlib轴上。还需要接受名为color和label的kwargs。
|
| --- | --- |
\ No newline at end of file
此差异已折叠。
......@@ -8,15 +8,12 @@ Shortcut to draw the full plot.
Use &lt;cite&gt;plot_joint&lt;/cite&gt; and &lt;cite&gt;plot_marginals&lt;/cite&gt; directly for more control.
| Parameters: | **joint_func, marginal_func: callables**
参数:**joint_func, marginal_func:callables**
> Functions to draw the bivariate and univariate plots.
|
| --- | --- |
| Returns: | **self** : JointGrid instance
返回值:`self`:JointGrid instance
> Returns &lt;cite&gt;self&lt;/cite&gt;.
|
| --- | --- |
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -8,12 +8,11 @@ Change how matplotlib color shorthands are interpreted.
Calling this will change how shorthand codes like “b” or “g” are interpreted by matplotlib in subsequent plots.
| Parameters: | **palette** : {deep, muted, pastel, dark, bright, colorblind}
参数:`palette`{deep, muted, pastel, dark, bright, colorblind}
> Named seaborn palette to use as the source of colors.
|
| --- | --- |
See also
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册