提交 c218bafb 编写于 作者: C cancan233

add zh version of 12, 23, 31

上级 d1104c2a
# seaborn.lineplot
# **seaborn.lineplot**
```py
```python
seaborn.lineplot(x=None, y=None, hue=None, size=None, style=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, dashes=True, markers=None, style_order=None, units=None, estimator='mean', ci=95, n_boot=1000, sort=True, err_style='band', err_kws=None, legend='brief', ax=None, **kwargs)
```
Draw a line plot with possibility of several semantic groupings.
The relationship between `x` and `y` can be shown for different subsets of the data using the `hue`, `size`, and `style` parameters. These parameters control what visual semantics are used to identify the different subsets. It is possible to show up to three dimensions independently by using all three semantic types, but this style of plot can be hard to interpret and is often ineffective. Using redundant semantics (i.e. both `hue` and `style` for the same variable) can be helpful for making graphics more accessible.
See the [tutorial](../tutorial/relational.html#relational-tutorial) for more information.
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.
参数:`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
`x``y`之间的关系可以使用`hue``size``style`参数为数据的不同子集显示。这些参数控制用于识别不同子集的视觉语义。通过使用所有三种语义类型,可以独立地显示三个维度,但是这种画图样式可能难以解释并且通常是无效的。使用冗余语义(即同一变量的`hue``style`)有助于使图形更易于理解。
> Grouping variable that will produce lines with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
请查看[指南](../tutorial/relational.html#relational-tutoria)获取更多信息。
`size`:name of variables in `data` or vector data, optional
默认情况下,图标在每个`x`值处汇总多个`y`值,并显示集中趋势的估计值和该估计值的置信区间。
> Grouping variable that will produce lines with different widths. Can be either categorical or numeric, although size mapping will behave differently in latter case.
参数:`x,y``data`或向量数据中变量的名称,可选择。
`style`:name of variables in `data` or vector data, optional
> 输入数据变量;必须是数字。可以直接传递数据或引用`data`中的列。
> Grouping variable that will produce lines with different dashes and/or markers. Can have a numeric dtype but will always be treated as categorical.
`hue`: `data`或向量数据中的变量名,可选。
`data`:DataFrame
> 分组变量,将生成具有不同颜色的线条的变量。可以是分类或数字,但颜色映射在后一种情况下的行为会有所不同。
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
`size`: `data`或向量数据中的变量名,可选。
`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.
`style`: `data`或向量数据中的变量名,可选。
`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.
`data`: 数据框架。
`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.
`palette`: 调色板名称,列表或字典,可选。
`sizes`:list, dict, or tuple, optional
> 用于`hue`变量的不同级别的颜色。应该是[`color_palette()`](seaborn.color_palette.html#seaborn.color_palette "seaborn.color_palette")可以解释的东西,或者是将色调级别映射到matplotlib颜色的字典。
> 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.
`hue_order`:列表,可选。
`size_order`:list, optional
> 指定`hue`变量级别的出现顺序,否则它们是根据数据确定的。当`hue`变量是数字时不相关。
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
`hue_norm`: 原则或者时归一化对象,可选。
`size_norm`:tuple or Normalize object, optional
> 当数值为数字时,应用于`hue`变量的颜色图数据单元的归一化。 如果是分类的,则不相关。
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
`sizes`:列表,字典,或者元组。可选。
`dashes`:boolean, list, or dictionary, optional
> 确定在使用`size`时如何选择大小的对象。它始终可以是大小值列表或`size`变量与大小的字典映射级别。当`size`是数字时,它也可以是一个元组,指定要使用的最小和最大大小,以便在此范围内对其他值进行规范化。
> 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.
`size_norm`:原则或者时归一化对象,可选。
`markers`:boolean, list, or dictionary, optional
> 当`size`变量是数字时,用于缩放绘图对象的数据单元中的归一化。
> 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.
`dashes`: 布尔值,列表或字典,可选。
`style_order`:list, optional
> 确定如何为`style`变量的不同级别绘制线条的对象。设置为`True`将使用默认的短划线代码,或者您可以将短划线代码列表或`style`变量的字典映射级别传递给短划线代码。设置为`False`将对所有子集使用实线。线段在matplotlib中指定: `(segment, gap)`长度的元组,或用于绘制实线的空字符串。
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
`markers`: 布尔值,列表或字典,可选。
`units`:{long_form_var}
> 确定如何为`style`变量的不同级别绘制标记的对象。 设置为“True”将使用默认标记,或者您可以传递标记列表或将`style`变量的字典映射到标记。 设置为“False”将绘制无标记线。 标记在matplotlib中指定。
> 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.
`style_order`:列表,可选。
`estimator`:name of pandas method or callable or None, optional
> 指定`style`变量级别的出现顺序,否则它们是从数据中确定的。`style`变量时数字不相关的。
> Method for aggregating across multiple observations of the `y` variable at the same `x` level. If `None`, all observations will be drawn.
`units`: {long_form_var}
`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.
`estimator`:pandas方法的名称或可调用或无,可选。
`n_boot`:int, optional
> 在相同的`x`级别上聚合`y`变量的多个观察值的方法。如果`None`,将绘制所有观察结果。
> Number of bootstraps to use for computing the confidence interval.
`ci`:整数或`sd`或None。可选。
`sort`:boolean, optional
> 与`estimator`聚合时绘制的置信区间大小。`sd`表示绘制数据的标准偏差。设置为`None`将跳过bootstrap。
> 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.
`n_boot`:整数,可选。
`err_style`:“band” or “bars”, optional
> 用于计算置信区间的bootstrap数。
> Whether to draw the confidence intervals with translucent error bands or discrete error bars.
`sort`:布尔值,可选。
`err_band`:dict of keyword arguments
> 如果为真,则数据将按x与y变量排序,否则行将按照它们在数据集中出现的顺序连接点。
> 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`.
`err_style`: `band``bars`,可选。
`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.
`err_band`:关键字参数字典。
`ax`:matplotlib Axes, optional
> 用于控制误差线美观的附加参数。 `kwargs`传递给`ax.fill_between`或`ax.errorbar`,具体取决于`err_style`。
> Axes object to draw the plot onto, otherwise uses the current Axes.
`legend``brief`,`full`,或`False`。可选。
`kwargs`:key, value mappings
> 如何绘制图例。如果`brief`,则数字`hue`和`size`变量将用均匀间隔值的样本表示。如果`full`,则每个组都会在图例中输入一个条目。如果为`False`,则不添加图例数据且不绘制图例。
> Other keyword arguments are passed down to `plt.plot` at draw time.
`ax`:matplotlib轴。可选。
> 将绘图绘制到的Axes对象,否则使用当前轴。
返回值:`ax`:matplotlib Axes
`kwargs`:关键,价值映射。
> Returns the Axes object with the plot drawn onto it.
> 其他关键字参数在绘制时传递给`plt.plot`。
返回值:`ax`:matplotlib轴
> 返回Axes对象,并在其上绘制绘图。
See also
也可以看看
Show the relationship between two variables without emphasizing continuity of the `x` variable.Show the relationship between two variables when one is categorical.
显示两个变量之间的关系,而不强调`x`变量的连续性。当两个变量时分类时,显示两个变量之间的关系。
Examples
例子
Draw a single line plot with error bands showing a confidence interval:
绘制单线图,其中错误带显示执行区间:
```py
>>> import seaborn as sns; sns.set()
......@@ -133,7 +126,7 @@ Draw a single line plot with error bands showing a confidence interval:
![http://seaborn.pydata.org/_images/seaborn-lineplot-1.png](img/25ad91543cb2ac105ccfb3efc544658a.jpg)
Group by another variable and show the groups with different colors:
按另一个变量分组并显示具有不同颜色的组:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -143,7 +136,7 @@ Group by another variable and show the groups with different colors:
![http://seaborn.pydata.org/_images/seaborn-lineplot-2.png](img/5d2d2c464b8872f780180217182517d4.jpg)
Show the grouping variable with both color and line dashing:
使用颜色和线条划线显示分组变量:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -153,7 +146,7 @@ Show the grouping variable with both color and line dashing:
![http://seaborn.pydata.org/_images/seaborn-lineplot-3.png](img/2e99f3ab69ddcc3a94df1ddb15068249.jpg)
Use color and line dashing to represent two different grouping variables:
使用颜色和线条划线来表示两个不同的分组变量:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -163,7 +156,7 @@ Use color and line dashing to represent two different grouping variables:
![http://seaborn.pydata.org/_images/seaborn-lineplot-4.png](img/7c717f27fe7c1e02672338abf7cad829.jpg)
Use markers instead of the dashes to identify groups:
使用标记而不是破折号来标识组:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal",
......@@ -174,7 +167,7 @@ Use markers instead of the dashes to identify groups:
![http://seaborn.pydata.org/_images/seaborn-lineplot-5.png](img/f82003c5544990262fe9a61a131d93ef.jpg)
Show error bars instead of error bands and plot the standard error:
显示错误条而不是错误带并绘制标准错误:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -184,7 +177,7 @@ Show error bars instead of error bands and plot the standard error:
![http://seaborn.pydata.org/_images/seaborn-lineplot-6.png](img/a92991eef59fbedc422f330f51697fe4.jpg)
Show experimental replicates instead of aggregating:
显示实验性重复而不是聚合:
```py
>>> ax = sns.lineplot(x="timepoint", y="signal", hue="event",
......@@ -195,7 +188,7 @@ Show experimental replicates instead of aggregating:
![http://seaborn.pydata.org/_images/seaborn-lineplot-7.png](img/d7a78945c0ae60bbd5ee9dfef15baba0.jpg)
Use a quantitative color mapping:
使用定量颜色映射:
```py
>>> dots = sns.load_dataset("dots").query("align == 'dots'")
......@@ -207,7 +200,7 @@ Use a quantitative color mapping:
![http://seaborn.pydata.org/_images/seaborn-lineplot-8.png](img/bc93752a335d8985139584678e19a2b9.jpg)
Use a different normalization for the colormap:
对colormap使用不同的归一化:
```py
>>> from matplotlib.colors import LogNorm
......@@ -219,7 +212,7 @@ Use a different normalization for the colormap:
![http://seaborn.pydata.org/_images/seaborn-lineplot-9.png](img/1848472fd25a5227de0c58b2fc43c865.jpg)
Use a different color palette:
使用不同的调色板:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -230,7 +223,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-lineplot-10.png](img/f758b47e18df4e0b8e31c3a3fb9a1634.jpg)
Use specific color values, treating the hue variable as categorical:
使用特定颜色值,将hue变量视为分类:
```py
>>> palette = sns.color_palette("mako_r", 6)
......@@ -242,7 +235,7 @@ Use specific color values, treating the hue variable as categorical:
![http://seaborn.pydata.org/_images/seaborn-lineplot-11.png](img/f91976efc3d73db2b134c57ba7dd86f3.jpg)
Change the width of the lines with a quantitative variable:
使用定量变量更改线条的宽度:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -253,7 +246,7 @@ Change the width of the lines with a quantitative variable:
![http://seaborn.pydata.org/_images/seaborn-lineplot-12.png](img/f7c110a02ff0dffcc8a6c88582b45b70.jpg)
Change the range of line widths used to normalize the size variable:
更改用于规范化size变量的线宽范围:
```py
>>> ax = sns.lineplot(x="time", y="firing_rate",
......@@ -264,7 +257,7 @@ Change the range of line widths used to normalize the size variable:
![http://seaborn.pydata.org/_images/seaborn-lineplot-13.png](img/438199f3698b863dd842a2f680c4a845.jpg)
Plot from a wide-form DataFrame:
DataFrame绘制:
```py
>>> import numpy as np, pandas as pd; plt.close("all")
......@@ -278,7 +271,7 @@ Plot from a wide-form DataFrame:
![http://seaborn.pydata.org/_images/seaborn-lineplot-14.png](img/25659857727e22d0f951f9c750bb29de.jpg)
Plot from a list of Series:
系列列表中绘制:
```py
>>> list_data = [wide_df.loc[:"2005", "a"], wide_df.loc["2003":, "b"]]
......@@ -288,7 +281,7 @@ Plot from a list of Series:
![http://seaborn.pydata.org/_images/seaborn-lineplot-15.png](img/711ff3dd5a0aef63679fe4174259ee3d.jpg)
Plot a single Series, pass kwargs to `plt.plot`:
绘制单个系列,将kwargs传递给`plt.plot`
```py
>>> ax = sns.lineplot(data=wide_df["a"], color="coral", label="line")
......@@ -297,7 +290,7 @@ Plot a single Series, pass kwargs to `plt.plot`:
![http://seaborn.pydata.org/_images/seaborn-lineplot-16.png](img/fde16964145ae355ddbbeae37728260a.jpg)
Draw lines at points as they appear in the dataset:
在数据集中出现的点处绘制线条:
```py
>>> x, y = np.random.randn(2, 5000).cumsum(axis=1)
......@@ -305,4 +298,4 @@ Draw lines at points as they appear in the dataset:
```
![http://seaborn.pydata.org/_images/seaborn-lineplot-17.png](img/05782b02c2faaf09a504b53a5a526445.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-lineplot-17.png](img/05782b02c2faaf09a504b53a5a526445.jpg)
......@@ -4,80 +4,77 @@
seaborn.pairplot(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind='scatter', diag_kind='auto', markers=None, height=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None, size=None)
```
Plot pairwise relationships in a dataset.
绘制数据集中的成对关系
By default, this function will create a grid of Axes such that each variable in `data` will by shared in the y-axis across a single row and in the x-axis across a single column. The diagonal Axes are treated differently, drawing a plot to show the univariate distribution of the data for the variable in that column.
默认情况下,此函数将创建一个Axes网络,以便`data`中的每个变量将在y轴上共享一行,并在x轴上共享一列。对角轴的处理方式并不同,以此绘制一个图表来显示该列中变量的数据的单变量分布。
It is also possible to show a subset of variables or plot different variables on the rows and columns.
还可以显示变量的子集或在行和列上绘制不同的变量。
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.
这是[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")的高级界面,旨在简化一些常见的样式。如果你需要更多的灵活性,你应该直接使用[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")
参数:`data`DataFrame
参数:`data`数据框架
> 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`变量中的值。
`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`中的变量分别用于图的行和列;即制作非方形图。
`kind`:{‘scatter’, ‘reg’}, optional
`kind`:{‘scatter’, ‘reg’}, 可选。
> Kind of plot for the non-identity relationships.
> 一种非等同关系的图类型
`diag_kind`:{‘auto’, ‘hist’, ‘kde’}, optional
`diag_kind`:{‘auto’, ‘hist’, ‘kde’}, 可选
> Kind of plot for the diagonal subplots. The default depends on whether `"hue"` is used or not.
> 对角线子图的一种图形。默认值取决于是否使用`hue`。
`markers`single matplotlib marker code or list, optional
`markers`单个matplotlit标记代码或列表,可选
> 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`标量,可选。
> Height (in inches) of each facet.
> 每个刻面的高度(以英寸为单位)
`aspect`scalar, optional
`aspect`标量,可选。
> Aspect * height gives the width (in inches) of each facet.
> Aspect\*height给出每个刻面的宽度(以英寸为单位)
`dropna`boolean, optional
`dropna`布尔值,可选。
> Drop missing values from the data before plotting.
> 在绘图之前删除数据中的缺失值。
`{plot, diag, grid}_kws`:dicts, optional
> Dictionaries of keyword arguments.
`{plot, diag, grid}_kws`:字典,可选。
> 关键字参数的字典。
返回值:`grid`:PairGrid
> Returns the underlying `PairGrid` instance for further tweaking.
> 返回底层的`PairGrid`实例以进一步调整。
See also
也可以看看
Subplot grid for more flexible plotting of pairwise relationships.
子图网络可以更灵活地绘制成对关系。
Examples
范例
Draw scatterplots for joint relationships and histograms for univariate distributions:
绘制联合关系地散点图和单变量分布的直方图:
```py
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
......@@ -88,7 +85,7 @@ Draw scatterplots for joint relationships and histograms for univariate distribu
![http://seaborn.pydata.org/_images/seaborn-pairplot-1.png](img/712c7f2cff4ed2c31b99bf5200838ae1.jpg)
Show different levels of a categorical variable by the color of plot elements:
通过绘图元素的颜色显示分类变量的不同级别:
```py
>>> g = sns.pairplot(iris, hue="species")
......@@ -97,7 +94,7 @@ Show different levels of a categorical variable by the color of plot elements:
![http://seaborn.pydata.org/_images/seaborn-pairplot-2.png](img/98c1e58e7427e940294084d2b4582ac8.jpg)
Use a different color palette:
使用不同的调色板:
```py
>>> g = sns.pairplot(iris, hue="species", palette="husl")
......@@ -106,7 +103,7 @@ Use a different color palette:
![http://seaborn.pydata.org/_images/seaborn-pairplot-3.png](img/f6d3d4030bc93eefcb054749cf90c36b.jpg)
Use different markers for each level of the hue variable:
`hue`变量的每个级别使用不同的标记:
```py
>>> g = sns.pairplot(iris, hue="species", markers=["o", "s", "D"])
......@@ -115,7 +112,7 @@ Use different markers for each level of the hue variable:
![http://seaborn.pydata.org/_images/seaborn-pairplot-4.png](img/6840daa5bd6d421f05969aeb76c74032.jpg)
Plot a subset of variables:
绘制变量的子集:
```py
>>> g = sns.pairplot(iris, vars=["sepal_width", "sepal_length"])
......@@ -124,7 +121,7 @@ Plot a subset of variables:
![http://seaborn.pydata.org/_images/seaborn-pairplot-5.png](img/87b11c84b7ec8551c2edf9a2ef987014.jpg)
Draw larger plots:
绘制更大的图:
```py
>>> g = sns.pairplot(iris, height=3,
......@@ -134,7 +131,7 @@ Draw larger plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-6.png](img/5e89b880399cf894d124b590416e7fb5.jpg)
Plot different variables in the rows and columns:
在行和列中绘制不同的变量:
```py
>>> g = sns.pairplot(iris,
......@@ -145,7 +142,7 @@ Plot different variables in the rows and columns:
![http://seaborn.pydata.org/_images/seaborn-pairplot-7.png](img/35f33d0939e4e10f46437f5690ad766b.jpg)
Use kernel density estimates for univariate plots:
对单变量图使用核密度估计:
```py
>>> g = sns.pairplot(iris, diag_kind="kde")
......@@ -154,7 +151,7 @@ Use kernel density estimates for univariate plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-8.png](img/cc2c3fb8414e50f2d9f95ab073457c23.jpg)
Fit linear regression models to the scatter plots:
将线性回归模型拟合到散点图:
```py
>>> g = sns.pairplot(iris, kind="reg")
......@@ -163,7 +160,7 @@ Fit linear regression models to the scatter plots:
![http://seaborn.pydata.org/_images/seaborn-pairplot-9.png](img/74befbc8e8cbc89474dd845fb49329ca.jpg)
Pass keyword arguments down to the underlying functions (it may be easier to use [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid") directly):
将关键字参数传递给底层函数(直接使用[`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid "seaborn.PairGrid")可能更容易)
```py
>>> g = sns.pairplot(iris, diag_kind="kde", markers="+",
......@@ -172,4 +169,4 @@ Pass keyword arguments down to the underlying functions (it may be easier to use
```
![http://seaborn.pydata.org/_images/seaborn-pairplot-10.png](img/0b688ef9f59240384ca84839d9707ce7.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-pairplot-10.png](img/0b688ef9f59240384ca84839d9707ce7.jpg)
......@@ -4,78 +4,78 @@
seaborn.clustermap(data, pivot_kws=None, method='average', metric='euclidean', z_score=None, standard_scale=None, figsize=None, cbar_kws=None, row_cluster=True, col_cluster=True, row_linkage=None, col_linkage=None, row_colors=None, col_colors=None, mask=None, **kwargs)
```
Plot a matrix dataset as a hierarchically-clustered heatmap.
将矩阵数据集绘制成分层聚类热图。
参数:**data:2D array-like**
> Rectangular data for clustering. Cannot contain NAs.
> 用于聚类的矩形数据,不能包含NA。
`pivot_kws`dict, optional
`pivot_kws`字典,可选。
> If <cite>data</cite> is a tidy dataframe, can provide keyword arguments for pivot to create a rectangular dataframe.
> 如果数据是整齐的数据框架,可以为pivot提供关键字参数以创建矩形数据框架。
`method`str, optional
`method`字符串,可选。
> 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)
> 用于计算聚类的链接方法。有关更多信息,请参阅文档scipy.cluster.hierarchy.linkage [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`字符串,可选。
> 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.
> 用于数据的距离度量。有关更多选项,请参阅scipy.spatial.distance.pdist文档。 [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) 要对行和列使用不同的度量(或方法),您可以子集构造每个链接矩阵,并将它们提供为`{row, col}_linkage.`
`z_score`:int or None, optional
`z_score`:int或None,可选。
> 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.
> 0(行)或1(列)。是否计算行或列的z分数。Z得分为 z = (x - mean)/std,因此每行(列)中的值将减去行(列)的平均值,然后除以行(列)的标准偏差。这可确保每行(列)的均值为0,方差为1.
`standard_scale`:int or None, optional
`standard_scale`:int或None, 可选。
> 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.
> 0(行)或1(列)。是否标准化该维度,即每行或每列的含义,减去最小值并将每个维度除以其最大值。
**figsize: tuple of two ints, optional**
**figsize: 两个整数的元组, 可选。**
> Size of the figure to create.
> 要创建的图形的大小。
`cbar_kws`dict, optional
`cbar_kws`字典, 可选。
> Keyword arguments to pass to `cbar_kws` in `heatmap`, e.g. to add a label to the colorbar.
> 要传递给`heatmap`中的`cbar_kws`的关键字参数,例如向彩条添加标签。
`{row,col}_cluster`bool, optional
`{row,col}_cluster`布尔值, 可选。
> If True, cluster the {rows, columns}.
> 如果为真,则对{rows, columns}进行聚类。
`{row,col}_linkage`:numpy.array, optional
`{row,col}_linkage`:numpy.array, 可选。
> Precomputed linkage matrix for the rows or columns. See scipy.cluster.hierarchy.linkage for specific formats.
> 行或列的预计算链接矩阵。有关特定格式,请参阅scipy.cluster.hierarchy.linkage.
`{row,col}_colors`:list-like or pandas DataFrame/Series, optional
`{row,col}_colors`:list-like或pandas DataFrame/Series, 可选。
> 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.
> 要为行或列标记的颜色列表。用于评估组内的样本是否聚集在一起。可以使用嵌套列表或DataFrame进行多种颜色级别的标注。如果以DataFrame或Series形式提供,则从DataFrames列名称或Series的名称中提取颜色标签。DataFrame/Series颜色也通过索引与数据匹配,确保以正确的顺序绘制颜色。
`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. Only used for visualizing, not for calculating.
> 如果通过,数据将不会显示在`mask`为真的单元格中。具有缺失值的单元格将自动被屏蔽。仅用于可视化,不用于计算。
`kwargs`other keyword arguments
`kwargs`其他关键字参数。
> All other keyword arguments are passed to `sns.heatmap`
> 所有其他关键字参数都传递给`sns.heatmap`
返回值:`clustergrid`:ClusterGrid
> A ClusterGrid instance.
> ClusterGrid实例。
Notes
注意点:
The returned object has a `savefig` method that should be used if you want to save the figure object without clipping the dendrograms.
返回的对象有一个`savefig`方法,如果要保存图形对象而不剪切树形图,则应使用该方法。
To access the reordered row indices, use: `clustergrid.dendrogram_row.reordered_ind`
要访问重新排序的行索引,请使用:`clustergrid.dendrogram_row.reordered_in`
Column indices, use: `clustergrid.dendrogram_col.reordered_ind`
列索引, 请使用: `clustergrid.dendrogram_col.reordered_ind`
Examples
范例
Plot a clustered heatmap:
绘制聚类热图。
```py
>>> import seaborn as sns; sns.set(color_codes=True)
......@@ -87,7 +87,7 @@ Plot a clustered heatmap:
![http://seaborn.pydata.org/_images/seaborn-clustermap-1.png](img/a7da372ba56ceec7b8b9e01f418bb1e3.jpg)
Use a different similarity metric:
使用不同的相似性指标。
```py
>>> g = sns.clustermap(iris, metric="correlation")
......@@ -96,7 +96,7 @@ Use a different similarity metric:
![http://seaborn.pydata.org/_images/seaborn-clustermap-2.png](img/e102a295ca812e5085369488cedb3dac.jpg)
Use a different clustering method:
使用不同的聚类方法。
```py
>>> g = sns.clustermap(iris, method="single")
......@@ -105,7 +105,7 @@ Use a different clustering method:
![http://seaborn.pydata.org/_images/seaborn-clustermap-3.png](img/64c061b1d37ef563dc9827fbb5c671a1.jpg)
Use a different colormap and ignore outliers in colormap limits:
使用不同的色彩映射并忽略色彩映射限制中的异常值。
```py
>>> g = sns.clustermap(iris, cmap="mako", robust=True)
......@@ -114,7 +114,7 @@ Use a different colormap and ignore outliers in colormap limits:
![http://seaborn.pydata.org/_images/seaborn-clustermap-4.png](img/b9161032a5adb7fb6694c185246664aa.jpg)
Change the size of the figure:
改变图的大小。
```py
>>> g = sns.clustermap(iris, figsize=(6, 7))
......@@ -123,7 +123,7 @@ Change the size of the figure:
![http://seaborn.pydata.org/_images/seaborn-clustermap-5.png](img/f7ed7c41c4e6dbed729d2a3ea8e2d0ff.jpg)
Plot one of the axes in its original organization:
绘制其原始组织中的一个轴。
```py
>>> g = sns.clustermap(iris, col_cluster=False)
......@@ -132,7 +132,7 @@ Plot one of the axes in its original organization:
![http://seaborn.pydata.org/_images/seaborn-clustermap-6.png](img/3acbff477d462457ef54fe167311c30e.jpg)
Add colored labels:
添加彩色标签。
```py
>>> lut = dict(zip(species.unique(), "rbg"))
......@@ -143,7 +143,7 @@ Add colored labels:
![http://seaborn.pydata.org/_images/seaborn-clustermap-7.png](img/da7ff8019c2f5f473c8c8958fd395e76.jpg)
Standardize the data within the columns:
标准化列中的数据。
```py
>>> g = sns.clustermap(iris, standard_scale=1)
......@@ -152,11 +152,11 @@ Standardize the data within the columns:
![http://seaborn.pydata.org/_images/seaborn-clustermap-8.png](img/4c9cb45bac2fd0bc0e8ebf7b6411ecc9.jpg)
Normalize the data within the rows:
正规化行内数据。
```py
>>> g = sns.clustermap(iris, z_score=0)
```
![http://seaborn.pydata.org/_images/seaborn-clustermap-9.png](img/5e7f4bf9cb93adb18b8275b2e6477182.jpg)
\ No newline at end of file
![http://seaborn.pydata.org/_images/seaborn-clustermap-9.png](img/5e7f4bf9cb93adb18b8275b2e6477182.jpg)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册