Adding titles and labels: Part 1

Introduzione alla visualizzazione dei dati con Seaborn

Content Team

DataCamp

Creating informative visualizations

Box plot of birth rate per region

Box plot of birth rate per region with title and labels

Introduzione alla visualizzazione dei dati con Seaborn

FacetGrid vs. AxesSubplot objects

Seaborn plots create two different types of objects: FacetGrid and AxesSubplot

g = sns.scatterplot(x="height", y="weight", data=df)

type(g)
> matplotlib.axes._subplots.AxesSubplot
Introduzione alla visualizzazione dei dati con Seaborn

An Empty FacetGrid

Empty 4x4 FacetGrid

Introduzione alla visualizzazione dei dati con Seaborn

FacetGrid vs. AxesSubplot objects

Object Type Plot Types Characteristics
FacetGrid relplot(), catplot() Can create subplots
AxesSubplot scatterplot(), countplot(), etc. Only creates a single plot
Introduzione alla visualizzazione dei dati con Seaborn

Adding a title to FacetGrid

g = sns.catplot(x="Region", 
                y="Birthrate", 
                data=gdp_data, 
                kind="box")

g.figure.suptitle("New Title")
plt.show()

Birth rate box plot with title added

Introduzione alla visualizzazione dei dati con Seaborn

Adjusting height of title in FacetGrid

g = sns.catplot(x="Region", 
                y="Birthrate", 
                data=gdp_data, 
                kind="box")

g.figure.suptitle("New Title", 
               y=1.03)

plt.show()

Birth rate plot with higher title

Introduzione alla visualizzazione dei dati con Seaborn

Let's practice!

Introduzione alla visualizzazione dei dati con Seaborn

Preparing Video For Download...