Spreidplots aanpassen

Introductie tot datavisualisatie met Seaborn

Content Team

DataCamp

Overzicht spreidplot

Toon de relatie tussen twee kwantitatieve variabelen

We zagen:

  • Subplots (col en row)
  • Subgroepen met kleur (hue)

Nieuwe aanpassingen:

  • Subgroepen met puntgrootte en -stijl
  • Punttransparantie aanpassen

Te gebruiken met zowel scatterplot() als relplot()

Introductie tot datavisualisatie met Seaborn

Subgroepen met puntgrootte

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips, 
            kind="scatter", 
            size="size")

plt.show()

Spreidplot met variërende puntgrootte

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introductie tot datavisualisatie met Seaborn

Puntgrootte en hue

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips, 
            kind="scatter", 
            size="size",
            hue="size")

plt.show()

Spreidplot met variërende puntgrootte en kleur

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introductie tot datavisualisatie met Seaborn

Subgroepen met puntstijl

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips, 
            kind="scatter", 
            hue="smoker", 
            style="smoker")

plt.show()

Spreidplot met variërende kleur en stijl

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introductie tot datavisualisatie met Seaborn

Punttransparantie aanpassen

import seaborn as sns
import matplotlib.pyplot as plt

# Stel alpha in tussen 0 en 1
sns.relplot(x="total_bill", 
            y="tip", 
            data=tips, 
            kind="scatter", 
            alpha=0.4)

plt.show()

Spreidplot met transparantere punten

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Introductie tot datavisualisatie met Seaborn

Laten we oefenen!

Introductie tot datavisualisatie met Seaborn

Preparing Video For Download...