Plotting with the FacetGrid() method

Let's start by looking at how to plot multi-dimensional plots with the FacetGrid method, a shown in the following code:

g = sns.FacetGrid(df, col="Sex", hue='Survived')g.map(plt.hist, "Age");g.add_legend();

The output of the preceding code should look like the following screenshot:

Here, we have used the FacetGrid method to draw two side-by-side histograms for male and female passengers. This side-by-side display helps us to compare the survival rates of male and female passengers by their age. To draw this, we first created a grid using the FacetGrid method. We then passed in our dataset's DataFrame columns ...

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.