Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
孊ぶ Summarizing Data with Box Plots | Section
Statistical Visualization with Seaborn

Summarizing 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()
タスク

スワむプしおコヌディングを開始

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.

解答

Switch to desktop実践的な緎習のためにデスクトップに切り替える䞋蚘のオプションのいずれかを利甚しお、珟圚の堎所から続行する
すべお明確でしたか

どのように改善できたすか

フィヌドバックありがずうございたす

セクション 1. 章 11
single

single

AIに質問する

expand

AIに質問する

ChatGPT

䜕でも質問するか、提案された質問の1぀を詊しおチャットを始めおください

some-alt