In [1]:
from __future__ import print_function, division
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
In [2]:
x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x), x, np.cos(x));
In [3]:
import seaborn as sns
sns.set()
plt.plot(x, np.sin(x), x, np.cos(x));
In [4]:
data = np.random.multivariate_normal([0, 0], [[5, 2], [2, 2]], size=2000)
data = pd.DataFrame(data, columns=['x', 'y'])
for col in 'xy':
plt.hist(data[col], normed=True, alpha=0.5)
In [5]:
for col in 'xy':
sns.kdeplot(data[col], shade=True)
In [6]:
sns.distplot(data['x']);
In [7]:
sns.kdeplot(data);
In [8]:
with sns.axes_style('white'):
sns.jointplot("x", "y", data, kind='kde');
In [9]:
with sns.axes_style('white'):
sns.jointplot("x", "y", data, kind='hex')
In [10]:
iris = sns.load_dataset("iris")
iris.head()
Out[10]:
In [11]:
tips = sns.load_dataset('tips')
tips.head()
Out[11]:
In [12]:
tips['tip_pct'] = 100 * tips['tip'] / tips['total_bill']
grid = sns.FacetGrid(tips, row="sex", col="time", margin_titles=True)
grid.map(plt.hist, "tip_pct", bins=np.linspace(0, 40, 15));
In [13]:
with sns.axes_style(style='ticks'):
g = sns.factorplot("day", "total_bill", "sex", data=tips, kind="box")
g.set_axis_labels("Day", "Total Bill");
In [14]:
with sns.axes_style('white'):
sns.jointplot("total_bill", "tip", data=tips, kind='hex')
In [15]:
sns.jointplot("total_bill", "tip", data=tips, kind='reg');
In [16]:
planets = sns.load_dataset('planets')
planets.head()
Out[16]:
In [17]:
with sns.axes_style('white'):
g = sns.factorplot("year", data=planets, aspect=1.5)
g.set_xticklabels(step=5)
In [18]:
with sns.axes_style('white'):
g = sns.factorplot("year", data=planets, aspect=4.0,
hue='method', order=range(2001, 2015), kind="count")
g.set_ylabels('Number of Planets Discovered')
In [ ]: