Figure-level interface for drawing relational plots onto a FacetGrid.
This function provides access to several different axes-level functions that show the relationship between two variables with semantic mappings of subsets. The `kind` parameter selects the underlying axes-level function to use:
绘制相关关系图像到FacetGrid的图像级别接口。
*[`scatterplot()`](seaborn.scatterplot.html#seaborn.scatterplot"seaborn.scatterplot")(with`kind="scatter"`; the default)
Extra keyword arguments are passed to the underlying function, so you should refer to the documentation for each to see kind-specific options.
额外的关键字参数会被传递给隐含的函数,因此使用时应当参考对应函数的文档去了解各种选项。
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.
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.
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.
> Grouping variable that will produce elements with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.
> Grouping variable that will produce elements with different sizes. Can be either categorical or numeric, although size mapping will behave differently in latter case.
> Grouping variable that will produce elements with different styles. Can have a numeric dtype but will always be treated as categorical.
> 将会产生具有不同风格的元素的变量进行分组。这些变量可以为数值型,但是通常会被当做类别变量处理。
`data`:DataFrame
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
> 长格式的DataFrame,每列是一个变量,每行是一个观察值。
`row, col`:names of variables in `data`, optional
`row, col`:`data`中的变量名,可选
> Categorical variables that will determine the faceting of the grid.
> 确定网格的分面的类别变量。
`col_wrap`:int, optional
`col_wrap`:int, 可选
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
> 以此宽度“包裹”列变量,以便列分面跨越多行。与`row`分面不兼容。
`row_order, col_order`:lists of strings, optional
`row_order, col_order`:字符串列表,可选
> 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`:色盘名,列表,或者字典,可选
> 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.
> 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`变量层级出现的顺序,否则会根据数据确定。当`hue`变量为数值型时与此无关。
`hue_norm`:tuple or Normalize object, optional
`hue_norm`:元组或者Normalize对象,可选
> 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.
> Specified order for appearance of the `size` variable levels, otherwise they are determined from the data. Not relevant when the `size` variable is numeric.
> Normalization in data units for scaling plot objects when the `size` variable is numeric.
> 当`size`变量为数值型时,用于数据单元的scaling plot对象的标准化。
`legend`:“brief”, “full”, or False, optional
`legend`:“brief”, “full”, 或者False, 可选
> 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.
Show point estimates and confidence intervals as rectangular bars.
条形图以矩形条的方式展示数据的点估值和置信区间
A bar plot represents an estimate of central tendency for a numeric variable with the height of each rectangle and provides some indication of the uncertainty around that estimate using error bars. Bar plots include 0 in the quantitative axis range, and they are a good choice when 0 is a meaningful value for the quantitative variable, and you want to make comparisons against it.
For datasets where 0 is not a meaningful value, a point plot will allow you to focus on differences between levels of one or more categorical variables.
对于数据集中的0值没有实际意义的情况,散点图可以让您专注于一个或多个分类变量之间的差异。
It is also important to keep in mind that a bar 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.
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.
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.
> Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
> 绘制类别变量的顺序,如果没有,则从数据对象中推断绘图顺序。
`estimator`:callable that maps vector -> scalar, optional
`estimator`:映射向量 -> 标量, optional
> Statistical function to estimate within each categorical bin.
> 统计函数用于估计每个分类纸条中的值。.
`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.
> Number of bootstrap iterations to use when computing confidence intervals.
> 计算置信区间需要的Boostrap迭代次数。
`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.
> 采样单元的标识符,用于执行多级bootstrap并解释重复测量设计。
`orient`:“v” | “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.
> Color for all of the elements, or seed for a gradient palette.
> 作用于所有元素的颜色,或者渐变色的种子。
`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.
> 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.
> 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
> Color for the lines that represent the confidence interval.
> 表示置信区间的线的颜色。
`errwidth`:float, optional
> Thickness of error bar lines (and caps).
> 误差条的线的厚度。
`capsize`:float, optional
> Width of the “caps” on error bars.
> 误差条端部的宽度。
`dodge`:bool, optional
**dodge** : 布尔型, optional
> When hue nesting is used, whether elements should be shifted along the categorical axis.
`ax`:matplotlib Axes, optional
> Axes object to draw the plot onto, otherwise uses the current Axes.
> 指定一个Axes用于绘图,如果不指定,则使用当前的Axes。
`kwargs`:key, value mappings
> Other keyword arguments are passed through to `plt.bar` at draw time.
> 其他的关键词参数在绘图时通过 `plt.bar` 传入。
返回值:`ax`:matplotlib Axes
> Returns the Axes object with the plot drawn onto it.
> 返回有图表绘制的Axes对象。
See also
Show the counts of observations in each categorical bin.Show point estimates and confidence intervals using scatterplot glyphs.Combine a categorical plot with a class:<cite>FacetGrid</cite>.
Use [`catplot()`](seaborn.catplot.html#seaborn.catplot"seaborn.catplot") to combine a [`barplot()`](#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:
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.
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.
> 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 -> list of values mapping
`hue_kws`:参数字典 -> 值列表映射
> 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).
| [`__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. |
> 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`.
Plot with a univariate function on each diagonal subplot.
在每一个对角线子图上用一个单变量函数绘制。
参数:`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`.
Plot with a bivariate function on the off-diagonal subplots.
在非对角线子图上用一个双变量函数绘图。
参数:`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`.
Plot with a bivariate function on the lower diagonal subplots.
在下对角线子图上用一个双变量函数绘图。
参数:`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`.
Plot with a bivariate function on the upper diagonal subplots.
在上对角线子图上用一个双变量函数绘图。
参数:`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`.
| [`__init__`](#seaborn.JointGrid.__init__"seaborn.JointGrid.__init__")(x, y[, data, height, ratio, space, …]) | Set up the grid of subplots. |
| `annotate`(func[, template, stat, loc]) | Annotate the plot with a statistic about the relationship. |
| [`plot`](seaborn.JointGrid.plot.html#seaborn.JointGrid.plot"seaborn.JointGrid.plot")(joint_func, marginal_func[, annot_func]) | Shortcut to draw the full plot. |
| [`plot_joint`](seaborn.JointGrid.plot_joint.html#seaborn.JointGrid.plot_joint"seaborn.JointGrid.plot_joint")(func, **kwargs) | Draw a bivariate plot of <cite>x</cite> and <cite>y</cite>. |
| [`plot_marginals`](seaborn.JointGrid.plot_marginals.html#seaborn.JointGrid.plot_marginals"seaborn.JointGrid.plot_marginals")(func, **kwargs) | Draw univariate plots for <cite>x</cite> and <cite>y</cite> separately. |
> This must take a 1d array of data as the first positional argument, it must plot on the “current” axes, and it must accept a “vertical” keyword argument to orient the measure dimension of the plot vertically.
Return a parameter dict to scale elements of the figure.
This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by .8, 1.3, and 1.6, respectively.
This function returns an object that can be used in a `with` statement to temporarily change the context parameters.
参数:`context`:dict, None, or one of {paper, notebook, talk, poster}
> Separate scaling factor to independently scale the size of the font elements.
> 参数集或者是预设集合的名字
`rc`:dict, optional
`font_scale`:浮点数,可选
> Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.
> 单独的缩放因子可以独立缩放字体元素大小
`rc`:dict,可选
> 参数映射以覆盖预设的seaborn的文本字典中的值。这只更新被视为文本定义的一部分的参数。
See also
也可参见
set the matplotlib parameters to scale plot elementsreturn a dict of parameters defining a figure styledefine the color palette for a plot
This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by .8, 1.3, and 1.6, respectively.
参数:`context`:dict, None, or one of {paper, notebook, talk, poster}
> A dictionary of parameters or the name of a preconfigured set.
`font_scale`:float, optional
> Separate scaling factor to independently scale the size of the font elements.
`rc`:dict, optional
> Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.
See also
return a dictionary of rc parameters, or use in a `with` statement to temporarily set the context.set the default parameters for figure styleset the default color palette for figures
> Named seaborn palette to use as the source of colors.
See also
Color codes can be set through the high-level seaborn style manager.Color codes can also be set through the function that sets the matplotlib color cycle.
Examples
Map matplotlib color codes to the default seaborn palette.