You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
408 KiB
408 KiB
<html>
<head>
</head>
</html>
Grids¶
Imports¶
In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
The Data¶
In [32]:
df = pd.read_csv('StudentsPerformance.csv')
In [33]:
df.head()
Out[33]:
catplot()¶
In [9]:
# Kind Options are: “point”, “bar”, “strip”, “swarm”, “box”, “violin”, or “boxen”
sns.catplot(x='gender',y='math score',data=df,kind='box')
Out[9]:
In [11]:
sns.catplot(x='gender',y='math score',data=df,kind='box',row='lunch')
Out[11]:
In [13]:
sns.catplot(x='gender',y='math score',data=df,kind='box',row='lunch',col='test preparation course')
Out[13]:
Pairgrid¶
Grid that pairplot is built on top of, allows for heavy customization of the pairplot seen earlier.
In [16]:
g = sns.PairGrid(df)
g = g.map_upper(sns.scatterplot)
g = g.map_diag(sns.kdeplot, lw=2)
g = g.map_lower(sns.kdeplot, colors="red")
In [24]:
g = sns.PairGrid(df, hue="gender", palette="viridis",hue_kws={"marker": ["o", "+"]})
g = g.map_upper(sns.scatterplot, linewidths=1, edgecolor="w", s=40)
g = g.map_diag(sns.distplot)
g = g.map_lower(sns.kdeplot)
g = g.add_legend();
# Safely ignore the warning, its telling you it didn't use the marker for kde plot
FacetGrid¶
In [4]:
sns.FacetGrid(data=df,col='gender',row='lunch')
Out[4]:
In [25]:
g = sns.FacetGrid(data=df,col='gender',row='lunch')
g = g.map(plt.scatter, "math score", "reading score", edgecolor="w")
g.add_legend()
Out[25]:
In [26]:
# https://stackoverflow.com/questions/43669229/increase-space-between-rows-on-facetgrid-plot
In [29]:
g = sns.FacetGrid(data=df,col='gender',row='lunch')
g = g.map(plt.scatter, "math score", "reading score", edgecolor="w")
g.add_legend()
plt.subplots_adjust(hspace=0.4, wspace=1)