Build Linked Small Multiples with Plotly Express Faceting
Use Plotly Express facet_col and facet_row to create small-multiples grids from one DataFrame, then link axes and style all panels at once.
24 Jan 2026, 06:24 UTC

The problem: six regions, one trend line
You are looking at a tidy DataFrame with columns for date, region, and conversion rate. Your stakeholder wants to see how each region's trend compares, but side-by-side charts are easier to scan than one crowded line plot. The manual route—calling plotly.graph_objects.make_subplots, adding one trace per region, and syncing axes by hand—works, but it is verbose and easy to get wrong as the number of regions grows.
The useful takeaway: Plotly Express can split that same DataFrame into a grid of small multiples in a single figure call. You keep one Figure object, apply shared styling across every panel, and link axes so zooming one panel updates its row or column.
Map columns to a grid
In Plotly Express, small multiples means repeating the same chart type for each level of a categorical column. Pass the column name to facet_col for vertical panels, facet_row for horizontal panels, or both for a matrix. facet_col_wrap forces a wrap after N columns when a single categorical dimension has many levels.
Each panel gets a strip label showing its facet value, and Plotly Express assigns internal subplot IDs such as x2, y2, x3, and y3 behind the scenes.
Worked example: conversion rate by region
Run this in a Jupyter notebook cell or a Python script. You need a standard Python environment with plotly and pandas installed; no administrative permissions are required.
import pandas as pd
import plotly.express as px
# Placeholder data: replace with your own DataFrame and column names.
df = pd.DataFrame({
"date": pd.date_range("2024-01-01", periods=12, freq="ME"),
"region": ["North", "South", "East", "West"] * 3,
"conversion_rate": [0.02, 0.03, 0.025, 0.018, 0.021, 0.029, 0.027, 0.019, 0.022, 0.031, 0.026, 0.020],
})
fig = px.line(
df,
x="date",
y="conversion_rate",
facet_col="region",
facet_col_wrap=2,
title="Conversion rate by region",
)
# Apply one marker style to every trace in every panel.
fig.update_traces(mode="lines+markers", marker=dict(size=6))
# Link x-axes across columns and y-axes across rows.
fig.update_xaxes(matches="x")
fig.update_yaxes(matches="y")
fig.show()
Expected checks after the cell runs:
- The browser or notebook output shows one figure object containing four panels, not four separate figures.
- Each panel carries a strip label such as "region=North" above the plot area.
- Zooming inside one panel updates the linked panels in the same row or column.
Programmatic check: inspect fig.layout for subplot axis references and confirm len(fig.data) equals the number of traces you expect. If you add more facet levels, the trace count grows accordingly.
Risks: faceting multiplies traces and subplots. With dozens of facet levels or large DataFrames, rendering slows and the exported HTML file can become large. Categorical axes do not always behave the same way as numeric axes when you use matches.
Trade-off: convenience versus layout control
Faceting is ideal when every panel shares the same x and y semantics and you want a single exportable artifact for HTML, a static image, or a Dash app. It is less suitable when panels need different axis types, unrelated scales, or completely different chart types. In those cases, build the subplots manually with make_subplots.
Plotly Express faceting behavior is version dependent. Older plotly.py releases may not support facet_col_wrap or may render strip labels differently. Check your installed version with:
import plotly
print(plotly.__version__)
If the version is old, upgrade plotly.py or avoid facet_col_wrap.
Verify the result
- Confirm
type(fig).__name__isFigureand there is only one object. - Hover over a point in one panel and confirm the hover template shows the expected facet value.
- Zoom into one panel; linked panels sharing
matches="x"should update together. - Export to HTML (
fig.write_html("output.html")) and check the file size; if it is unexpectedly large, reduce facet levels or downsample the data.
Bottom line
Start with px.line, px.scatter, or px.bar plus facet_col or facet_row when you need small multiples from a tidy DataFrame. Use update_traces for shared styling and matches for linked axes, then verify the panel count and file size before shipping.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.