Een boxplot maken

Introductie tot datavisualisatie met Seaborn

Content Team

DataCamp

Wat is een boxplot?

  • Toont de verdeling van kwantitatieve data
  • Zie mediaan, spreiding, scheefheid en uitschieters
  • Maakt vergelijking tussen groepen makkelijk

Boxplot van totaalbedrag per weekdag

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

Een boxplot maken

import matplotlib.pyplot as plt
import seaborn as sns

g = sns.catplot(x="time", 
                y="total_bill",
                data=tips, 
                kind="box")

plt.show()

Boxplot van totaalbedrag per tijdstip van de dag

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

Volgorde van categorieën wijzigen

import matplotlib.pyplot as plt
import seaborn as sns

g = sns.catplot(x="time", 
                y="total_bill",
                data=tips, 
                kind="box",
                order=["Dinner", 
                       "Lunch"])

plt.show()

Boxplot met diner vóór lunch

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

Buitenbeentjes weglaten

import matplotlib.pyplot as plt
import seaborn as sns

g = sns.catplot(x="time", 
                y="total_bill",
                data=tips, 
                kind="box",
                showfliers=False)

plt.show()

Boxplot met buitenbeentjes weggelaten

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

Snorren aanpassen met `whis`

  • Standaard reiken de snorren tot 1,5 × de interkwartielafstand
  • Laat ze reiken tot 2,0 × IQR: whis=2.0
  • Toon 5e en 95e percentiel: whis=[5, 95]
  • Toon min- en maxwaarden: whis=[0, 100]
Introductie tot datavisualisatie met Seaborn

Snorren aanpassen met `whis`

import matplotlib.pyplot as plt
import seaborn as sns

g = sns.catplot(x="time", 
                y="total_bill",
                data=tips, 
                kind="box",
                whis=[0, 100])

plt.show()

Boxplot met snorren op minimum en maximum

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...