Chapter 2
Chapter 2
Styles
I N T E R M E D I AT E D ATA V I S U A L I Z AT I O N W I T H S E A B O R N
Chris Mo
Instructor
Setting Styles
Seaborn has default con gurations that can be applied with sns.set()
sns.set()
df['Tuition'].plot.hist()
sns.set_style('white')
sns.displot(df['Tuition'])
sns.despine(left=True)
Chris Mo
Instructor
Defining a color for a plot
Seaborn supports assigning colors to plots using matplotlib color codes
sns.set(color_codes=True)
sns.displot(df['Tuition'], color='g')
sns.palplot(sns.color_palette("Blues", 12))
Chris Mo
Instructor
Matplotlib Axes
Most customization available through matplotlib Axes objects
fig, ax = plt.subplots()
sns.histplot(df['Tuition'], ax=ax)
ax.set(xlabel='Tuition 2013-14')
fig, ax = plt.subplots()
sns.histplot(df['Tuition'], ax=ax)
ax.set(xlabel="Tuition 2013-14",
ylabel="Distribution", xlim=(0, 50000),
title="2013-14 Tuition and Fees Distribution")