Skip to content

04-Comparison-Plots

Updated
17 Sept 2026
1 min read
5 sections
Page 40 of 117
Python & Machine Learning

Comparison Plots with pairplot() and jointplot()

Imports

The Data

python
df = pd.read_csv("StudentsPerformance.csv")
python
df.head()
Out · table
gender
race/ethnicity
parental level of education
lunch
test preparation course
48 more lines
math score
reading score
writing score
0
female
group B
bachelor's degree
standard
none
72
72
74
1
female
group C
some college
standard
completed
69
90
88
2
female
group B
master's degree
standard
none
90
95
93
3
male
group A
associate's degree
free/reduced
none
47
57
44
4
male
group C
some college
standard
none
76
78
75

jointplot

python
sns.jointplot(x='math score',y='reading score',data=df)
Out · result
<seaborn.axisgrid.JointGrid at 0x23f9ed8dd08>
Out · plot
Output 1
python
sns.jointplot(x='math score',y='reading score',data=df,kind='hex')
Out · result
<seaborn.axisgrid.JointGrid at 0x23fa1027308>
Out · plot
Output 2
python
sns.jointplot(x='math score',y='reading score',data=df,kind='kde')
Out · result
<seaborn.axisgrid.JointGrid at 0x23fa11d4108>
Out · plot
Output 3

pairplot

python
sns.pairplot(df)
Out · result
<seaborn.axisgrid.PairGrid at 0x23fa12eb608>
Out · plot
Output 4
python
sns.pairplot(df,hue='gender',palette='viridis')
Out · result
<seaborn.axisgrid.PairGrid at 0x23fa18c8908>
Out · plot
Output 5
python
sns.pairplot(df,hue='gender',palette='viridis',corner=True)
Out · result
<seaborn.axisgrid.PairGrid at 0x23fa1e07948>
Out · plot
Output 6
python
sns.pairplot(df,hue='gender',palette='viridis',diag_kind='hist')
Out · result
<seaborn.axisgrid.PairGrid at 0x23fa190ef88>
Out · plot
Output 7