seaborn.FacetGrid()的使用

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)

用于绘制条件关系的多图网格。

__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)

初始化matplotlib图和FacetGrid对象。

此类将数据集映射到排列在行和列网格中的多个轴上,这些行对应于数据集中的变量级别。它产生的图通常被称为“格子”,“格子”或“小多”图形。
它还可以用色调参数表示第三个变量的级别,该参数绘制不同颜色的不同数据子集。这使用颜色来解析第三维上的元素,但仅在彼此之上绘制子集,并且不会像接受色调的轴级函数那样为特定可视化定制hue参数。
当使用从数据集推断语义映射的seaborn函数时,必须注意在各个方面之间同步这些映射。在大多数情况下,使用图形级函数(例如relplot()或catplot())比直接使用FacetGrid更好。
基本流程是使用数据集和用于构造网格的变量初始化FacetGrid对象。然后,通过调用FacetGrid.map()或FacetGrid.map_dataframe(),可以将一个或多个绘图函数应用于每个子集。最后,可以使用其他方法调整绘图,以执行更改轴标签,使用不同刻度或添加图例等操作。

Parameters:

data : DataFrame

Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.

row, col, hue : strings

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.

col_wrap : int, optional

“Wrap” the column variable at this width, so that the column facets span multiple rows. Incompatible with a row facet.

share{x,y} : bool, ‘col’, or ‘row’ optional

If true, the facets will share y axes across columns and/or x axes across rows.

height : scalar, optional

Height (in inches) of each facet. See also: aspect.

aspect : scalar, optional

Aspect ratio of each facet, so that aspect * height gives the width of each facet in inches.

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(), or a dictionary mapping hue levels to matplotlib colors.

{row,col,hue}_order : lists, optional

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

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).

legend_out : bool, optional

If True, the figure size will be extended, and the legend will be drawn outside the plot on the center right.

despine : boolean, optional

Remove the top and right spines from the plots.

margin_titles : bool, optional

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.

{x, y}lim: tuples, optional

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.

gridspec_kws : dict, optional

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.

你可能感兴趣的:(seaborn.FacetGrid()的使用)