Using PairGrid and pairplot

Visualisasi Data Lanjutan dengan Seaborn

Chris Moffitt

Instructor

Pairwise relationships

  • PairGrid shows pairwise relationships between data elements

PairGrid example

Visualisasi Data Lanjutan dengan Seaborn

Creating a PairGrid

  • The PairGrid follows similar API to FacetGrid
g = sns.PairGrid(df, vars=["Fair_Mrkt_Rent","Median_Income"])
g = g.map(sns.scatterplot)

PairGrid Scatterplot example

Visualisasi Data Lanjutan dengan Seaborn

Customizing the PairGrid diagonals

g = sns.PairGrid(df, vars=["Fair_Mrkt_Rent", "Median_Income"])
g = g.map_diag(sns.histplot)
g = g.map_offdiag(sns.scatterplot)

PairGrid customized example

Visualisasi Data Lanjutan dengan Seaborn

Pairplot

  • pairplot is a shortcut for the PairGrid
sns.pairplot(df, vars=["Fair_Mrkt_Rent","Median_Income"], kind="reg",
             diag_kind="hist")

pairplot example

Visualisasi Data Lanjutan dengan Seaborn

Customizing a pairplot

sns.pairplot(df.query("BEDRMS < 3"), 
             vars=["Fair_Mrkt_Rent",
             "Median_Income", "UTILITY"],
             hue="BEDRMS", palette="husl",
             plot_kws={"alpha": 0.5})

pairplot custom example

Visualisasi Data Lanjutan dengan Seaborn

Let's practice!

Visualisasi Data Lanjutan dengan Seaborn

Preparing Video For Download...