Skip to content

Plotly Subplots and Facets

Two ways to create multi-plot layouts

  1. Facets (Plotly Express): easiest for grid layouts — one line of code repeats the same chart across a category, split into a grid of small panels (“small multiples”).
  2. Subplots (plotly.subplotsplotly.subplots): full control — you place arbitrary, even different, chart types into any grid cell yourself.

Facets are for “show me this one chart, once per group.” Subplots are for “let me hand-place several different charts into one figure” (this is exactly what the dashboard page does).

Facets with Plotly Express

Facet example
import plotly.express as px
 
df = px.data.tips()
 
fig = px.scatter(
    df,
    x="total_bill",
    y="tip",
    color="sex",
    facet_col="day",
    title="Tips by day (facets)",
)
fig.show()
Facet example
import plotly.express as px
 
df = px.data.tips()
 
fig = px.scatter(
    df,
    x="total_bill",
    y="tip",
    color="sex",
    facet_col="day",
    title="Tips by day (facets)",
)
fig.show()

facet_col="day"facet_col="day" splits the data by the dayday column and draws one scatter panel per unique day, all sharing the same axis scale — so panels are directly comparable side by side.

sketch Small multiples: same chart, repeated per group p5.js
Faceting draws one identical mini-chart per category, all on the same scale, side by side.

Manual subplots

Subplots
import plotly.graph_objects as go
from plotly.subplots import make_subplots
 
fig = make_subplots(rows=1, cols=2, subplot_titles=["A", "B"])
 
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 4, 9], mode="lines", name="line"), row=1, col=1)
fig.add_trace(go.Bar(x=["x", "y", "z"], y=[5, 2, 6], name="bar"), row=1, col=2)
 
fig.update_layout(title_text="Two plots in one figure")
fig.show()
Subplots
import plotly.graph_objects as go
from plotly.subplots import make_subplots
 
fig = make_subplots(rows=1, cols=2, subplot_titles=["A", "B"])
 
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 4, 9], mode="lines", name="line"), row=1, col=1)
fig.add_trace(go.Bar(x=["x", "y", "z"], y=[5, 2, 6], name="bar"), row=1, col=2)
 
fig.update_layout(title_text="Two plots in one figure")
fig.show()

Unlike facets, the two panels here don’t have to share a scale, an x-axis meaning, or even a chart type — make_subplotsmake_subplots just gives you a grid of independent plotting areas.

Tips

  • Use facets when you’re comparing the same chart across categories on a shared scale.
  • Use subplots when mixing chart types, or when panels genuinely measure different things.
  • Too many facet panels (more than ~6-8) get cramped — consider filtering to the most important categories first.
diagram Choosing facets vs subplots mermaid
Facets repeat one chart per category on a shared scale; subplots hand-place arbitrary charts into a grid.

Next

Continue to: Animations in Plotly to show change over time or category using frames.

🧪 Try It Yourself

Exercise 1 – Facet by Category

Exercise 2 – Build a Subplot Grid

Exercise 3 – Mix Chart Types in One Figure

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did