seaborn.PairGrid

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

    See the for more information.

    1. __init__(data, hue=None, hue_order=None, palette=None, hue_kws=None, vars=None, x_vars=None, y_vars=None, diag_sharey=True, height=2.5, aspect=1, despine=True, dropna=True, size=None)

    Initialize the plot figure and PairGrid object.

    参数:data:DataFrame

    hue:string (variable name), optional

    Variable in data to map plot aspects to different colors.

    hue_order:list of strings

    Order for the levels of the hue variable in the palette

    palette:dict or seaborn color palette

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

    vars:list of variable names, optional

    Variables within data to use, otherwise use every column with a numeric datatype.

    height:scalar, optional

    Height (in inches) of each facet.

    aspect:scalar, optional

    Aspect * height gives the width (in inches) of each facet.

    :boolean, optional

    dropna:boolean, optional

    Drop missing values from the data before plotting.

    See also

    Easily drawing common uses of PairGrid.Subplot grid for plotting conditional relationships.

    Examples

    Draw a scatterplot for each pairwise relationship:

    1. >>> import matplotlib.pyplot as plt
    2. >>> import seaborn as sns; sns.set()
    3. >>> iris = sns.load_dataset("iris")
    4. >>> g = sns.PairGrid(iris)
    5. >>> g = g.map(plt.scatter)

    Show a univariate distribution on the diagonal:

    http://seaborn.pydata.org/_images/seaborn-PairGrid-2.png

    Color the points using a categorical variable:

    1. >>> g = sns.PairGrid(iris, hue="species")
    2. >>> g = g.map_offdiag(plt.scatter)
    3. >>> g = g.add_legend()

    Use a different style to show multiple histograms:

    1. >>> g = sns.PairGrid(iris, hue="species")
    2. >>> g = g.map_diag(plt.hist, histtype="step", linewidth=3)
    3. >>> g = g.map_offdiag(plt.scatter)
    4. >>> g = g.add_legend()

    http://seaborn.pydata.org/_images/seaborn-PairGrid-4.png

    Plot a subset of variables

    Pass additional keyword arguments to the functions

    1. >>> g = sns.PairGrid(iris)

    http://seaborn.pydata.org/_images/seaborn-PairGrid-6.png

    Use different variables for the rows and columns:

    1. >>> g = sns.PairGrid(iris,
    2. ... x_vars=["sepal_length", "sepal_width"],
    3. ... y_vars=["petal_length", "petal_width"])
    4. >>> g = g.map(plt.scatter)

    Use different functions on the upper and lower triangles:

    http://seaborn.pydata.org/_images/seaborn-PairGrid-8.png

    Use different colors and markers for each categorical level:

    1. >>> g = sns.PairGrid(iris, hue="species", palette="Set2",
    2. ... hue_kws={"marker": ["o", "s", "D"]})
    3. >>> g = g.add_legend()

    Methods

    | (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(func, kwargs) | Plot with the same function in every subplot. || (func, kwargs) | Plot with a univariate function on each diagonal subplot. || map_lower(func, kwargs) | Plot with a bivariate function on the lower diagonal subplots. || (func, kwargs) | Plot with a bivariate function on the off-diagonal subplots. || 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. |