In [1]:
import seaborn as sns
%matplotlib inline
In [7]:
flights = sns.load_dataset('flights')
In [10]:
tips = sns.load_dataset('tips')
In [11]:
tips.head()
Out[11]:
In [4]:
flights.head()
Out[4]:
In [12]:
tips.head()
Out[12]:
In [14]:
# Matrix form for correlation data
tips.corr()
Out[14]:
In [16]:
sns.heatmap(tips.corr())
Out[16]:
In [19]:
sns.heatmap(tips.corr(),cmap='coolwarm',annot=True)
Out[19]:
Or for the flights data:
In [23]:
flights.pivot_table(values='passengers',index='month',columns='year')
Out[23]:
In [24]:
pvflights = flights.pivot_table(values='passengers',index='month',columns='year')
sns.heatmap(pvflights)
Out[24]:
In [30]:
sns.heatmap(pvflights,cmap='magma',linecolor='white',linewidths=1)
Out[30]:
In [31]:
sns.clustermap(pvflights)
Out[31]:
Notice now how the years and months are no longer in order, instead they are grouped by similarity in value (passenger count). That means we can begin to infer things from this plot, such as August and July being similar (makes sense, since they are both summer travel months)
In [34]:
# More options to get the information a little clearer like normalization
sns.clustermap(pvflights,cmap='coolwarm',standard_scale=1)
Out[34]: