Seaborn可视化

seaborn与matplotlib

import matplotlib.pyplot as plt
plt.style.use('classic')
%matplotlib inline
import numpy as np
import pandas as pd

# Create some data
rng = np.random.RandomState(0)
x = np.linspace(0, 10, 500)
y = np.cumsum(rng.randn(500, 6), 0)

plt.plot(x, y)
plt.legend('ABCDEF', ncol=2, loc='upper left');

使用seaborn

import seaborn as sns
sns.set()
# same plotting code as above!
plt.plot(x, y)
plt.legend('ABCDEF', ncol=2, loc='upper left');

深入seaborn绘图

sns有很多绘图方法,例如:

for col in 'xy':
    plt.hist(data[col], normed=True, alpha=0.5)
sns.kdeplot(data[col], shade=True)
sns.distplot(data['x'])
sns.kdeplot(data);

with sns.axes_style('white'):
    sns.jointplot("x", "y", data, kind='kde');

with sns.axes_style('white'):
    sns.jointplot("x", "y", data, kind='hex')

sns.violinplot("gender", "split_frac", data=data,
               palette=["lightblue", "lightpink"]);

pair 分图

iris = sns.load_dataset("iris")
iris.head()

sns.pairplot(iris, hue='species', size=2.5);

各向分图

with sns.axes_style('white'):
    sns.jointplot("total_bill", "tip", data=tips, kind='hex')
![image.png](https://upload-images.jianshu.io/upload_images/14391893-f02a5a4d77339874.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

sns.jointplot("total_bill", "tip", data=tips, kind='reg');

![image.png](https://upload-images.jianshu.io/upload_images/14391893-cf8d58ca24a6b0d6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

你可能感兴趣的:(Seaborn可视化)