Plotting with the PairGrid() method 

Now let's look at how we can use the PairGrid method to draw grid-aware plots. We are using the MLB players dataset for this, as shown in the following code:

mlb = pd.read_csv('data-mlb-players.csv')mlb.head()

The output is as follows:


Let's create a plot with the following code:

g = sns.PairGrid(mlb, vars=["Height", "Weight"], hue="Position");g.add_legend();

Here, we have passed our dataset of MLB players, and we set vars to a list containing players' Height and Weight. We then set hue as Position. We then ...

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.