Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Summarizing Data with Box Plots | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Statistical Visualization with Seaborn

bookSummarizing Data with Box Plots

A boxplot is a standardized way of displaying the distribution of data based on a five-number summary:

  1. Minimum (lowest value excluding outliers);
  2. First quartile (Q1) (25th percentile);
  3. Median (50th percentile);
  4. Third quartile (Q3) (75th percentile);
  5. Maximum (highest value excluding outliers).

Why use a Boxplot?

It is the best tool for comparing distributions between groups. It immediately tells you:

  • Central tendency: where is the median line?;
  • Spread: how tall is the box? (the interquartile range);
  • Symmetry: is the median in the center of the box?;
  • Outliers: are there dots outside the whiskers?

Key Parameters

  • saturation: controls the intensity of the colors (0 to 1). Lower values make the colors more muted;
  • linewidth: controls the thickness of the box outlines and whiskers;
  • width: controls the width of the box itself.

Example

Here is a boxplot analyzing the "Tips" dataset. Notice how the dots representing outliers appear above the whiskers.

123456789101112131415161718
import seaborn as sns import matplotlib.pyplot as plt # Load dataset df = sns.load_dataset('tips') # Create a boxplot sns.boxplot( data=df, hue='day', x='day', y='total_bill', palette='coolwarm', linewidth=2, # Thicker lines saturation=0.7 # Slightly muted colors ) plt.show()
copy
Task

Swipe to start coding

Visualize the distance of planets discovered by different methods.

  1. Set the style to 'ticks'. Customize the theme by passing a dictionary to change the background to 'grey' ('figure.facecolor') and the tick colors to 'white' ('xtick.color' and 'ytick.color').
  2. Create a boxplot using the planets dataset (df):
    • Map 'distance' to the x axis and 'method' to the y axis.
    • Set the box width to 0.6.
    • Make the lines thicker using linewidth=2.
    • Mute the colors significantly by setting saturation to 0.4.
    • Use the 'vlag' palette.
  3. Display the plot.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 11
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookSummarizing Data with Box Plots

Swipe to show menu

A boxplot is a standardized way of displaying the distribution of data based on a five-number summary:

  1. Minimum (lowest value excluding outliers);
  2. First quartile (Q1) (25th percentile);
  3. Median (50th percentile);
  4. Third quartile (Q3) (75th percentile);
  5. Maximum (highest value excluding outliers).

Why use a Boxplot?

It is the best tool for comparing distributions between groups. It immediately tells you:

  • Central tendency: where is the median line?;
  • Spread: how tall is the box? (the interquartile range);
  • Symmetry: is the median in the center of the box?;
  • Outliers: are there dots outside the whiskers?

Key Parameters

  • saturation: controls the intensity of the colors (0 to 1). Lower values make the colors more muted;
  • linewidth: controls the thickness of the box outlines and whiskers;
  • width: controls the width of the box itself.

Example

Here is a boxplot analyzing the "Tips" dataset. Notice how the dots representing outliers appear above the whiskers.

123456789101112131415161718
import seaborn as sns import matplotlib.pyplot as plt # Load dataset df = sns.load_dataset('tips') # Create a boxplot sns.boxplot( data=df, hue='day', x='day', y='total_bill', palette='coolwarm', linewidth=2, # Thicker lines saturation=0.7 # Slightly muted colors ) plt.show()
copy
Task

Swipe to start coding

Visualize the distance of planets discovered by different methods.

  1. Set the style to 'ticks'. Customize the theme by passing a dictionary to change the background to 'grey' ('figure.facecolor') and the tick colors to 'white' ('xtick.color' and 'ytick.color').
  2. Create a boxplot using the planets dataset (df):
    • Map 'distance' to the x axis and 'method' to the y axis.
    • Set the box width to 0.6.
    • Make the lines thicker using linewidth=2.
    • Mute the colors significantly by setting saturation to 0.4.
    • Use the 'vlag' palette.
  3. Display the plot.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 11
single

single

some-alt