Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Visualizing Categorical Scatter Plots | Section
Statistical Visualization with Seaborn
セクション 1.  9
single

single

bookVisualizing Categorical Scatter Plots

メニューを表示するにはスワイプしてください

In statistics, a categorical variable is a variable that can take on one of a limited number of possible values (e.g., "Day of Week", "Gender", "Country").

A stripplot is essentially a scatter plot where one of the axes represents a categorical variable. It visualizes the distribution of many individual one-dimensional values.

Why Use a Stripplot?

Unlike a histogram or a density plot which aggregates data, a stripplot shows every single observation as a dot. This is perfect for smaller datasets where you want to see the exact spread and identify outliers.

Key Parameters for Customization

Since dots can overlap (a problem called "overplotting"), stripplot offers several ways to make them distinct:

  • alpha: controls transparency (0 to 1). Setting this to a low value (e.g., 0.25) helps visualize density — darker areas mean more points;
  • size: changes the radius of the dots;
  • marker: changes the shape of the points (e.g., 'D' for diamonds, 's' for squares);
  • jitter: adds a small amount of random noise to the position of dots so they don't sit exactly on top of each other (enabled by default).

Live Example

Here is how to create a stripplot that uses transparency to handle overlapping data.

1234567891011121314151617
import seaborn as sns import matplotlib.pyplot as plt # Load dataset df = sns.load_dataset('tips') # Create a customized stripplot sns.stripplot( data=df, x='day', # Categorical axis y='total_bill', # Numerical axis alpha=0.5, # Make points semi-transparent size=10, # Make points larger jitter=True # Spread points out slightly ) plt.show()
copy
タスク

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

Visualize the distribution of bills per day with a customized style.

  1. Set the style to 'whitegrid'. Pass a dictionary to set the background color ('axes.facecolor') to 'aliceblue'.
  2. Create a stripplot using the tips dataset (df):
    • Map 'day' to the x axis and 'total_bill' to the y axis.
    • Color the points based on the 'smoker' status using hue.
    • Set the point size to 20.
    • Use the 'crest' palette.
    • Change the marker shape to diamonds using marker='D'.
    • Set the transparency alpha to 0.25.
  3. Display the plot.

解答

Switch to desktop実践的な練習のためにデスクトップに切り替える下記のオプションのいずれかを利用して、現在の場所から続行する
すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1.  9
single

single

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

some-alt