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
> 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
默认情况下,图标在每个`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.
> 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.
> 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.
> 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.
> Specified order for appearance of the `style` variable levels otherwise they are determined from the data. Not relevant when the `style` variable is numeric.
> 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
> 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.
> 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.
> 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
>>>importseabornassns;sns.set()
...
...
@@ -133,7 +126,7 @@ Draw a single line plot with error bands showing a confidence interval:
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.
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.
> 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.
Pass keyword arguments down to the underlying functions (it may be easier to use [`PairGrid`](seaborn.PairGrid.html#seaborn.PairGrid"seaborn.PairGrid") directly):
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)
> 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.
> 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.
> 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.
> 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.