seaborn.
pairplot
(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind='scatter', diag_kind='auto', markers=None, height=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None, size=None)¶Plot pairwise relationships in a dataset.
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
that is intended to
make it easy to draw a few common styles. You should use PairGrid
directly if you need more flexibility.
Parameters: | data : DataFrame
hue : string (variable name), optional
hue_order : list of strings
palette : dict or seaborn color palette
vars : list of variable names, optional
{x, y}_vars : lists of variable names, optional
kind : {‘scatter’, ‘reg’}, optional
diag_kind : {‘auto’, ‘hist’, ‘kde’}, optional
markers : single matplotlib marker code or list, optional
height : scalar, optional
aspect : scalar, optional
dropna : boolean, optional
{plot, diag, grid}_kws : dicts, optional
|
---|---|
Returns: | grid : PairGrid
|
See also
PairGrid
Examples
Draw scatterplots for joint relationships and histograms for univariate distributions:
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
>>> iris = sns.load_dataset("iris")
>>> g = sns.pairplot(iris)
Show different levels of a categorical variable by the color of plot elements:
>>> g = sns.pairplot(iris, hue="species")
Use a different color palette:
>>> g = sns.pairplot(iris, hue="species", palette="husl")
Use different markers for each level of the hue variable:
>>> g = sns.pairplot(iris, hue="species", markers=["o", "s", "D"])
Plot a subset of variables:
>>> g = sns.pairplot(iris, vars=["sepal_width", "sepal_length"])
Draw larger plots:
>>> g = sns.pairplot(iris, height=3,
... vars=["sepal_width", "sepal_length"])
Plot different variables in the rows and columns:
>>> g = sns.pairplot(iris,
... x_vars=["sepal_width", "sepal_length"],
... y_vars=["petal_width", "petal_length"])
Use kernel density estimates for univariate plots:
>>> g = sns.pairplot(iris, diag_kind="kde")
Fit linear regression models to the scatter plots:
>>> g = sns.pairplot(iris, kind="reg")
Pass keyword arguments down to the underlying functions (it may be easier
to use PairGrid
directly):
>>> g = sns.pairplot(iris, diag_kind="kde", markers="+",
... plot_kws=dict(s=50, edgecolor="b", linewidth=1),
... diag_kws=dict(shade=True))