seaborn.pairplot
- seaborn.pairplot(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind=’scatter’, diag_kind=’hist’, markers=None, size=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None)
Parameters:
- data : DataFrame
Tidy (long-form) dataframe where each column is a variable and each row is an observation.- hue : (根据某一类别进行分类,比如code)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
Set of colors for mapping the hue variable. If a dict, keys should be values in the hue variable.- vars : **DataFrame列名称**list of variable names, optional
Variables within data to use, otherwise use every column with a numeric datatype.
{x, y}_vars : lists of variable names, optional
Variables within data to use separately for the rows and columns of the figure; i.e. to make a non-square plot.
-* kind* : {‘scatter’, ‘reg’}, optional
Kind of plot for the non-identity relationships.- diag_kind : (对脚线图形的种类){‘hist’, ‘kde’}, optional
Kind of plot for the diagonal subplots.- markers : single matplotlib marker code or list, optional
Either the marker to use for all datapoints or a list of markers with a length the same as the number of levels in the hue variable so that differently colored points will also have different scatterplot markers.- size : scalar, optional
Height (in inches) of each facet.- aspect : scalar, optional
Aspect * size gives the width (in inches) of each facet.- dropna : boolean, optional
Drop missing values from the data before plotting.
{plot, diag, grid}_kws : dicts, optional
Dictionaries of keyword arguments.
%matplotlib inline
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
sns.set_style('darkgrid')
f,axes=plt.subplots(3,3,figsize=(9,9),sharex=True,sharey=True)
stock=pd.read_csv('sample.csv',index_col=0)
sns.kdeplot(stock.open,stock.high)
<matplotlib.axes._subplots.AxesSubplot at 0x3ad9e748>
sns.boxplot(stock.open,stock.high)
<matplotlib.axes._subplots.AxesSubplot at 0x277f22e8>
sns.lmplot(x='ma10',y='ma20',data=stock)
<seaborn.axisgrid.FacetGrid at 0x31245dd8>
sns.jointplot('ma10','price_change',data=stock,kind='reg')
<seaborn.axisgrid.JointGrid at 0x31c85898>
g=sns.pairplot(stock.ix[:,5:10])
sns.pairplot(stock.ix[:,10:],hue='code')
<seaborn.axisgrid.PairGrid at 0x5a860a20>
vars=['ma5','ma10','v_ma5']
sns.pairplot(stock,vars=vars,hue='code',size=5,kind='scatter',diag_kind='kde',diag_kws=dict(shade=True))
<seaborn.axisgrid.PairGrid at 0x6fc2ee10>
sns.pairplot(stock,vars=vars,hue='code',size=5,kind='scatter',plot_kws=dict(s=50, edgecolor="b", linewidth=1),diag_kind='kde',diag_kws=dict(shade=True))
<seaborn.axisgrid.PairGrid at 0x71608588>