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
セクション 1.  11
single

single

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
タスク

スワイプしてコーディングを開始

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