In [1]:
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
sns.set_style('whitegrid')
In [3]:
titanic = sns.load_dataset('titanic')
In [4]:
titanic.head()
Out[4]:
In [5]:
titanic.shape
Out[5]:
Recreate the plots below using the titanic dataframe. There are very few hints since most of the plots can be done with just one or two lines of code and a hint would basically give away the solution. Keep careful attention to the x and y labels for hints.
Note! In order to not lose the plot image, make sure you don't code in the cell that is directly above the plot, there is an extra cell above that one which won't overwrite that plot!
In [6]:
sns.jointplot(x='fare', y='age', data=titanic)
Out[6]:
In [41]:
Out[41]:
In [9]:
sns.distplot(titanic['fare'], kde=False, hist=True)
Out[9]:
In [44]:
Out[44]:
In [14]:
sns.boxplot(x='class', y='age', data=titanic)
Out[14]:
In [45]:
Out[45]:
In [16]:
sns.swarmplot(x='class', y='age', data=titanic)
Out[16]:
In [46]:
Out[46]:
In [17]:
sns.countplot(x='sex', data=titanic)
Out[17]:
In [47]:
Out[47]:
In [20]:
sns.heatmap(titanic.corr())
Out[20]:
In [48]:
Out[48]:
In [26]:
import matplotlib.pyplot as plt
fg = sns.FacetGrid(data=titanic ,col='sex')
fg.map(plt.hist, 'age')
Out[26]:
In [49]:
Out[49]: