Flexibly plot a univariate distribution of observations.
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.
> Whether to plot a gaussian kernel density estimate.
`kde`:布尔值,可选参数。
`rug`:bool, optional
> 是否绘制高斯核密度估计图。
> Whether to draw a rugplot on the support axis.
`rug`:布尔值,可选参数。
`fit`:random variable object, optional
> 是否在横轴上绘制观测值竖线。
> An object with <cite>fit</cite> method, returning a tuple that can be passed to a <cite>pdf</cite> method a positional arguments following an grid of values to evaluate the pdf on.
`bw`:{‘scott’ | ‘silverman’ | scalar | pair of scalars },可选参数
> 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.
> Number of discrete points in the evaluation grid.
> 评估网格中的离散点数。
`cut`:scalar, optional
`cut`:标量,可选参数。
> Draw the estimate to cut * bw from the extreme data points.
> 绘制估计值以从极端数据点切割* bw。
`clip`:pair of scalars, or pair of pair of scalars, optional
`clip`:一对标量,可选参数。
> Lower and upper bounds for datapoints used to fit KDE. Can provide a pair of (low, high) bounds for bivariate plots.
> 用于拟合KDE图的数据点的上下限值。可以为双变量图提供一对(上,下)边界。
`legend`:bool, optional
`legend`:布尔值,可选参数。
> If True, add a legend or label the axes when possible.
> 如果为True,为绘制的图像添加图例或者标记坐标轴。
`cumulative`:bool, optional
`cumulative`:布尔值,可选参数。
> If True, draw the cumulative distribution estimated by the kde.
> 如果为True,则绘制kde估计图的累积分布。
`shade_lowest`:bool, optional
`shade_lowest`:布尔值,可选参数。
> If True, shade the lowest contour of a bivariate KDE plot. Not relevant when drawing a univariate plot or when `shade=False`. Setting this to `False` can be useful when you want multiple densities on the same Axes.
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`.
> 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.
> 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.
> 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.
Initialize the matplotlib figure and FacetGrid object.
初始化matplotlib画布和FacetGrid对象。
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.
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.
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.
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.
> Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
> 整洁的(“长形式”)dataframe数据,其中每一列是一个变量,每一行是一个观察实例。
`row, col, hue`:strings
`row, col, hue`:字符串。
> 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.
> “Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a `row` facet.
> 以此参数值来限制网格的列维度,以便列面跨越多行。与`row`面不兼容。
`share{x,y}`:bool, ‘col’, or ‘row’ optional
`share{x,y}`:布尔值,'col' 或 'row'可选
> If true, the facets will share y axes across columns and/or x axes across rows.
> 如果为true,则跨列共享y轴或者跨行共享x轴。
`height`:scalar, optional
`height`:标量,可选参数。
> Height (in inches) of each facet. See also: `aspect`.
> 每个图片的高度设定(以英寸为单位)。另见:*aspect*
`aspect`:scalar, optional
`aspect`:标量,可选参数。
> Aspect ratio of each facet, so that `aspect * height` gives the width of each facet in inches.
> 每个图片的纵横比,因此aspect * height给出每个图片的宽度,单位为英寸。
`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.
> 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.
`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).
> Limits for each of the axes on each facet (only relevant when share{x, y} is True.
> 每个图片上每个轴的限制(仅当share {x,y}为True时才相关)。
`subplot_kws`:dict, optional
`subplot_kws`:字典,可选参数。
> Dictionary of keyword arguments passed to matplotlib subplot(s) methods.
> 传递给matplotlib subplot(s)方法的关键字参数字典。
`gridspec_kws`:dict, optional
`gridspec_kws`:字典,可选参数。
> Dictionary of keyword arguments passed to matplotlib’s `gridspec` module (via `plt.subplots`). Requires matplotlib >= 1.4 and is ignored if `col_wrap` is not `None`.
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").
(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).
| [`__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. |