Creating Dashboards with Plotly
Dashboard idea
Section titled “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
Section titled “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.
flowchart LR A["sales DataFrame"] --> B["px.bar(...)
Sales by city"] C["trend DataFrame"] --> D["px.line(...)
Orders trend"] B --> E["make_subplots(rows, cols)"] D --> E E --> F["fig.add_trace(...) per chart"] F --> G["One figure, one layout,
fig.show() renders the dashboard"]
Example: 2 charts in one view
Section titled “Example: 2 charts in one view”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
Section titled “Keeping it readable”- Give every subplot its own clear
subplot_titlesentry — 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
Section titled “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.
Continue to: Choropleth Maps for visualizing metrics across geographic regions.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Create a Subplot Grid
Section titled “Exercise 1 – Create a Subplot Grid”Exercise 2 – Add a Trace to a Specific Cell
Section titled “Exercise 2 – Add a Trace to a Specific Cell”Exercise 3 – Label Each Panel
Section titled “Exercise 3 – Label Each Panel”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading