Seaborn
I was impressed that even a graph that is a little troublesome to draw with matplotlib can be drawn relatively easily with seaborn.
If you try to draw this with matplotlib, it will look something like this. It may be wrong because it is super suitable,
import itertools
fig, axes = plt.subplots(2, 3)
col_f = 'Pclass'
col_f_domain = [1, 2, 3]
row_f = 'Sex'
row_f_domain = ['male', 'female']
for i, (r, c) in enumerate(itertools.product(row_f_domain, row_f_domain)):
row_i = i // 3
col_i = i % 3
ax = axes[row_i][col_i]
# (The following is omitted)
Oh yeah, don't turn the for loop. This is one line for seaborn ...
sns.relplot(x='Age', y='Fare', hue='Survived', col='Pclass', row='Sex', data=train_data)
When performing EDA (Exploratory Data Analysis), many graphs are drawn while changing the features and levels to be compared, so there is a tool that can quickly apply such complicated plots. It comes in handy. On the contrary, matplotlib is good at being able to handle itching that cannot be reached with such high-level tools. I think I should use matplotlib to draw plots that Seaborn cannot draw.
Recommended Posts