Rug plot

Seaborn basics

2 min read

Published Oct 7 2025


24
0
0
0

ChartsGraphsMatplotlibNumPyPandasPythonSeabornVisualisation

seaborn.rugplot() draws small tick marks (rugs) along an axis to represent individual data points.

Each tick represents one observation — giving a sense of the distribution of data along a single dimension.

It’s often used:

  • On its own for simple data density visualisation, or
  • As an addition to other plots (e.g., histplot(), kdeplot()) to show the actual observations behind a smooth curve.

Syntax:

sns.rugplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    height=0.025,
    expand_margins=True,
    palette=None,
    linewidth=None,
    alpha=None,
    ax=None,
    **kwargs
)

Parameters:

  • data = DataFrame containing the data
  • x, y = Variables to plot (usually one)
  • hue = Adds subgroups (coloured rugs)
  • height = Length of each rug line (fraction of axis)
  • expand_margins = Expands axis limits to fit the rugs
  • palette = Colour palette for hue groups
  • linewidth = Thickness of each rug tick
  • alpha = Transparency (0–1)
  • ax = Axis to plot on (if combining with other plots)




Basic example

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(data=tips, x="total_bill")
plt.show()

Each small vertical tick represents one observation of total_bill. The density of ticks gives a quick sense of data concentration.


seaborn rug plot basic example





Horizontal orientation

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(data=tips, y="total_bill")
plt.show()

Plots rug ticks along the y-axis instead of x.


seaborn rug plot horizontal example





Add hue (subgroups)

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(data=tips, x="total_bill", hue="sex", palette="Set2")
plt.show()

Different colours represent different categories (e.g., Male vs. Female). Overlapping colours show how groups overlap in data distribution.


seaborn rug plot hue example





Customize rug appearance

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(
    data=tips,
    x="total_bill",
    height=0.05,
    linewidth=2,
    alpha=0.7,
    color="darkred"
)
plt.show()

Taller and thicker ticks make the rug more visible.


seaborn rug plot style example





Overlay rug on other plots


On a Histogram:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.histplot(data=tips, x="total_bill", bins=20, color="skyblue")
sns.rugplot(data=tips, x="total_bill", color="black")
plt.show()

The rugplot shows exact data points below the histogram bars.


seaborn rug plot histogram example


On a KDE Plot:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.kdeplot(data=tips, x="total_bill", fill=True, color="lightgreen")
sns.rugplot(data=tips, x="total_bill", color="black")
plt.show()

Combines smooth distribution (KDE) with exact data locations (rug).


seaborn rug plot kde example





Bivariate rugplot (x and y)

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(data=tips, x="total_bill", y="tip")
plt.show()

Adds small ticks on both the x- and y-axes, showing marginal distributions.


seaborn rug plot both axis example





Hue with multiple variables

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

sns.rugplot(data=tips, x="total_bill", y="tip", hue="sex", palette="Set1", alpha=0.6)
plt.show()

Coloured rugs along both axes for each group.


seaborn rug plot both axis hue example

Products from our shop

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet - Print at Home Designs

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Mouse Mat

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Travel Mug

Docker Cheat Sheet Mug

Docker Cheat Sheet Mug

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet - Print at Home Designs

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Mouse Mat

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Travel Mug

Vim Cheat Sheet Mug

Vim Cheat Sheet Mug

SimpleSteps.guide branded Travel Mug

SimpleSteps.guide branded Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript - Travel Mug

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Dark

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Embroidered T-Shirt - Light

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - White

Developer Excuse Javascript Mug - Black

Developer Excuse Javascript Mug - Black

SimpleSteps.guide branded stainless steel water bottle

SimpleSteps.guide branded stainless steel water bottle

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Light

Developer Excuse Javascript Hoodie - Dark

Developer Excuse Javascript Hoodie - Dark

© 2025 SimpleSteps.guide
AboutFAQPoliciesContact