Python Central HubSign in

Data Analytics with Python / Phase 7: Interactive Visualization with Plotly

Creating Dashboards with Plotly

Combine multiple interactive charts into a simple dashboard-style layout using Plotly subplots.

Dashboard idea

A "dashboard" can be as simple as:

  • a few key charts
  • shown together
  • with a consistent theme

You don't need a full web framework to get this far — Plotly supports multi-plot layouts via make_subplots, letting you assemble several independent figures into one shareable view.

How the pieces fit together

Building a Plotly dashboard is really a small pipeline: each data source feeds one chart, and every chart's traces get placed into a shared grid figure.

diagram From data sources to a mini dashboard mermaid
Each dataset becomes one chart; make_subplots collects every chart's traces into a single figure and layout.

Example: 2 charts in one view

Python
import pandas as pd
import plotly.express as px
from plotly.subplots import make_subplots
import plotly.graph_objects as go
 
sales = pd.DataFrame({
    "city": ["Pune", "Delhi", "Mumbai", "Bengaluru"],
    "sales": [120, 180, 90, 160],
})
 
trend = pd.DataFrame({
    "day": [1, 2, 3, 4, 5],
    "orders": [120, 140, 130, 160, 155],
})
 
bar = px.bar(sales, x="city", y="sales", title="Sales by city")
line = px.line(trend, x="day", y="orders", markers=True, title="Orders trend")
 
fig = make_subplots(rows=1, cols=2, subplot_titles=("Sales", "Orders"))
 
for trace in bar.data:
    fig.add_trace(trace, row=1, col=1)
for trace in line.data:
    fig.add_trace(trace, row=1, col=2)
 
fig.update_layout(title_text="Mini dashboard", showlegend=False)
fig.show()

Note the pattern: build each chart normally with Plotly Express, then copy its .data traces into a shared make_subplots grid. You get one figure — one HTML export, one set of hover/zoom controls — instead of juggling several separate files.

Keeping it readable

  • Give every subplot its own clear subplot_titles entry — a dashboard with unlabeled panels forces the reader to guess.
  • Keep a consistent color scheme across panels so the same category means the same color everywhere.
  • Don't cram more than 4-6 charts into one static grid; beyond that, a real dashboarding tool (below) manages layout and filtering far better.

Next step

If you want a full web app dashboard with filters, dropdowns, and cross-chart interactivity, the next tool is usually Dash or Streamlit — both build on top of the same Plotly figures you already know how to create.

Check your understanding

quizCheck yourself
  1. Which function builds the multi-chart grid in the lesson?

    Show answer

    B — make_subplots — plotly.subplots.make_subplots creates a grid figure that you fill with traces.

  2. How does the lesson combine a px.bar and a px.line into one figure?

    Show answer

    B — Copies each chart's .data traces in with add_trace and row/col — Build each chart normally, then loop over its .data and call fig.add_trace with the row and col.

  3. In make_subplots(rows=1, cols=2, subplot_titles=("Sales", "Orders")), how many panels result?

    Show answer

    B — Two side by side — One row and two columns give two panels next to each other, with the titles labeling them.

  4. Clicking a bar should filter the line chart next to it. What do you need?

    Show answer

    D — A tool like Dash or Streamlit — Cross-chart interactivity outgrows make_subplots and needs a dashboarding tool such as Dash or Streamlit.

Next

Continue to: Choropleth Maps for visualizing metrics across geographic regions.

🧪 Try It Yourself

Exercise 1 – Create a Subplot Grid

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 2 – Add a Trace to a Specific Cell

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Exercise 3 – Label Each Panel

exerciseYour turn

Tab indents. Press Escape, then Tab, to leave the editor. Control plus Enter runs the code; Control plus Shift plus Enter submits it.

Output
Press Run to see what your code prints.

Was this page helpful?

Let us know how we did