In [1]:
import numpy as np
from numpy.random import randn
import pandas as pd
from scipy import stats
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
In [2]:
flights_dframe = sns.load_dataset('flights')
In [3]:
flight_dframe = flights_dframe.pivot('month', 'year', 'passengers')
In [4]:
flight_dframe
Out[4]:
In [5]:
sns.heatmap(flight_dframe)
Out[5]:
In [6]:
sns.heatmap(flight_dframe, annot=True, fmt='d')
Out[6]:
In [7]:
sns.heatmap(flight_dframe, center=flight_dframe.loc['January', 1955])
Out[7]:
In [11]:
f, (axis1, axis2) = plt.subplots(2,1)
yearly_flights = flight_dframe.sum()
years = pd.Series(yearly_flights.index.values)
years = pd.DataFrame(years)
flights = pd.Series(yearly_flights.values)
flights = pd.DataFrame(flights)
year_dframe = pd.concat((years, flights), axis=1)
year_dframe.columns = ['Year', 'Flights']
sns.barplot('Year','Flights', data=year_dframe, ax = axis1)
sns.heatmap(flight_dframe, cmap='Blues', ax=axis2, cbar_kws={'orientation': 'horizontal'})
Out[11]:
In [12]:
sns.clustermap(flight_dframe)
Out[12]:
In [13]:
sns.clustermap(flight_dframe, col_cluster=False)
Out[13]:
In [16]:
sns.clustermap(flight_dframe, standard_scale=1, linewidths=.5)
Out[16]:
In [17]:
sns.clustermap(flight_dframe, standard_scale=0, linewidths=.5)
Out[17]:
In [18]:
sns.clustermap(flight_dframe, z_score=1, linewidths=.5)
Out[18]:
In [ ]: