Rug Plots

Learn how to plot, design, and interpret rug plots for data visualizations.

Overview

The rug plot shows the data distribution by drawing ticks on the axis of the plot. It adds ticks for each data point along the axis so that areas where most of the data points fall look darker than the rest. It’s used on top of other plots to show the data distribution.

Plotting rug plots

Let’s get started by importing the required libraries and setting the default seaborn theme. Next, we import the penguins dataset and store it in the peng_df DataFrame. We remove null values from the DataFrame using the dropna() method and pass inplace=True to modify the original DataFrame peng_df.

Press + to interact
peng_df.dropna(inplace=True)

Let’s plot a rug plot for a single variable, bill_length_mm, which represents the bill length of different penguin species, using the sns.rugplot() function, as shown in the plot below. The plot shows lines or ticks drawn along the x-axis for each observation. We can see that most of the penguins have a ...