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
flight_dframe = sns.load_dataset('flights')
flight_dframe.head()
flight_dframe = flight_dframe.pivot('month','year','passengers')
flight_dframe
sns.heatmap(flight_dframe)
# 数字を書き込めます。
sns.heatmap(flight_dframe, annot=True, fmt='d')
#中心を指定して、色を変えられます。
sns.heatmap(flight_dframe, center=flight_dframe.loc['January',1955])
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', y='Flights', data=year_dframe, ax=axis1)
sns.heatmap(flight_dframe, cmap='Blues', ax=axis2, cbar_kws={'orientation':'horizontal'})
sns.clustermap(flight_dframe)
sns.clustermap(flight_dframe, col_cluster=False)
sns.clustermap(flight_dframe, standard_scale=1)
sns.clustermap(flight_dframe, standard_scale=0)
sns.clustermap(flight_dframe, z_score=1)