Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Visualizing Categorical Scatter Plots | Section
Statistical Visualization with Seaborn

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
Task

Swipe to start coding

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.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 9
single

single

Ask AI

expand

Ask AI

ChatGPT

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

close

bookVisualizing Categorical Scatter Plots

Swipe to show menu

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
Task

Swipe to start coding

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.

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Β 9
single

single

some-alt