Python Data Science Library Mastery • Training 05
Article-Training • Interactive Visualization

Plotly

Turn Data into Interactive Visual Stories for the Browser

Build charts people can explore, not just look at.

DataFrame → Plotly Express → Interactive Figure → Explore → Refine → Share → Decision
x = month • y = revenue • color = region
↓
📈
🖱️
🔎
🏷️
🎨
🪟
🌐
📤
↓
Hover • zoom • filter • compare • share
8modules
24interactive practices
50%certificate unlock
6market-ready visual skills
Your Learning Record

Make the practice count

Enter your name. Complete at least 12 practice cases to unlock the Certificate of Participation.

Practice progress0 / 24
MODULE 01
🧠

The Plotly Mental Model: Figure, Traces and Layout

Plotly builds a figure object that contains visual data layers called traces plus layout instructions. Plotly Express creates that figure quickly; Graph Objects lets you work closer to the structure.

👁️
See it this way

Think of a dashboard chart as a stage: traces are the actors and layout is the stage design. Plotly Express casts the scene quickly; Graph Objects lets you direct every element.

Core ideas

  • A figure contains data traces plus layout
  • Plotly Express is the high-level API for rapid charts
  • Graph Objects exposes lower-level figure components
  • Most Plotly charts render as interactive browser graphics
Try this
import plotly.express as px

fig = px.scatter(
    df,
    x="requests",
    y="resolution_days",
    color="department"
)

fig.show()
✅

Start with Plotly Express unless you already know you need specialized trace-by-trace control.

Practice the decision, not just the syntax

Practice 1
What is the fastest high-level entry point for common Plotly charts?
Practice 2
What does a Plotly figure mainly contain?
Practice 3
When is graph_objects especially useful?
MODULE 02
⚡

Plotly Express: Build Analytical Charts Fast

Plotly Express turns tidy DataFrames into complete interactive figures with concise commands. The analytical question should determine the chart type—not the library’s feature list.

👁️
See it this way

A manager asks whether workload is related to resolution time. One scatter plot can show the relationship; color can separate departments and hover can expose details.

Core ideas

  • px.scatter() for relationships
  • px.line() for ordered change such as time
  • px.bar() for category comparisons
  • color, size and symbol add semantic dimensions
Try this
fig = px.line(
    monthly,
    x="month",
    y="revenue",
    color="region",
    markers=True,
    title="Monthly Revenue by Region"
)

fig.show()
✅

Choose the simplest chart that answers the business question. Interactivity does not rescue a weak chart choice.

Practice the decision, not just the syntax

Practice 4
Which function is a natural choice for two numeric variables?
Practice 5
Which argument commonly maps a category to color?
Practice 6
Which chart is a natural choice for values over ordered time?
MODULE 03
🖱️

Hover, Color, Size and Custom Data: Add Meaning

Interactive charts become valuable when exploration reveals useful context. Plotly lets you encode dimensions visually and carry extra fields into hover without cluttering the canvas.

👁️
See it this way

Instead of labeling every point with department, employee count and budget, show only the essential visual encodings and reveal the extra context on hover.

Core ideas

  • hover_name highlights a primary label
  • hover_data adds or formats tooltip fields
  • size can encode another numeric variable
  • custom_data carries fields for custom hover or callbacks
Try this
fig = px.scatter(
    df,
    x="requests",
    y="resolution_days",
    color="department",
    size="budget",
    hover_name="service",
    hover_data={"manager": True, "budget": ":$,.0f"}
)

fig.show()
✅

Use hover to reveal secondary context, not to hide the chart’s main message.

Practice the decision, not just the syntax

Practice 7
What does hover_data let you control?
Practice 8
What can size encode in a bubble chart?
Practice 9
Why use custom_data?
MODULE 04
🪟

Facets and Animation: Compare Many Views without Many Files

Faceting creates small multiples that preserve a common visual grammar. Animation can show change through ordered frames, but both techniques work only when the result remains easy to read.

👁️
See it this way

You need to compare the same KPI across branches. Instead of eight separate charts, facet by branch and keep the axes and visual encodings consistent.

Core ideas

  • facet_col and facet_row create small multiples
  • animation_frame steps through an ordered variable
  • shared encodings make comparisons easier
  • too many panels or frames can overload the viewer
Try this
fig = px.bar(
    df,
    x="month",
    y="requests",
    color="service",
    facet_col="branch",
    facet_col_wrap=2
)

fig.show()
✅

Facet when side-by-side comparison matters; animate only when motion reveals a pattern that static views would obscure.

Practice the decision, not just the syntax

Practice 10
What does facet_col create?
Practice 11
What is a good use of animation_frame?
Practice 12
What is the main risk of too many facets?
MODULE 05
🎨

Layout, Labels and Themes: Make Interaction Readable

A Plotly chart still needs visual hierarchy. Titles, axis labels, legends, templates and spacing should reduce interpretation time rather than decorate the page.

👁️
See it this way

A chart can be technically interactive and still fail because the title says “Figure 1,” the axis says “value,” and the legend is ambiguous. Clear language is part of the analysis.

Core ideas

  • update_layout() controls figure-level presentation
  • update_xaxes() and update_yaxes() refine axes
  • templates provide reusable visual defaults
  • labels should use business language, not raw field names
Try this
fig.update_layout(
    title="Service Demand vs Resolution Time",
    template="plotly_white",
    legend_title_text="Department",
    margin=dict(l=40, r=30, t=70, b=40)
)

fig.update_xaxes(title="Monthly Requests")
fig.update_yaxes(title="Average Resolution Days")
✅

Design the chart so a first-time viewer can understand the question before touching hover or zoom.

Practice the decision, not just the syntax

Practice 13
Where do you usually refine titles, axes and legend?
Practice 14
What does a template provide?
Practice 15
Why avoid unnecessary 3D effects?
MODULE 06
🧩

Graph Objects and Subplots: Take Deeper Control

When a chart needs mixed trace types, custom layering or specialized subplot layouts, Graph Objects gives direct access to figure components while keeping Plotly’s interactive engine.

👁️
See it this way

You want bars for monthly cases and a line for average handling time in one coordinated figure. That is a good moment to move below the Plotly Express abstraction.

Core ideas

  • go.Figure() constructs figures explicitly
  • add_trace() adds visual layers
  • make_subplots() creates multi-panel structures
  • mixed trace types enable richer analytical compositions
Try this
from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(specs=[[{"secondary_y": True}]])

fig.add_trace(go.Bar(x=df["month"], y=df["cases"], name="Cases"))
fig.add_trace(
    go.Scatter(x=df["month"], y=df["avg_days"], name="Avg Days"),
    secondary_y=True
)

fig.show()
✅

Use Graph Objects when the analytical composition demands control—not just because it looks more advanced.

Practice the decision, not just the syntax

Practice 16
What does go.Figure() give you?
Practice 17
Which helper is commonly used for multi-panel subplots?
Practice 18
What is a trace?
MODULE 07
🔎

Interactive Exploration: Zoom, Legends and Range Controls

Plotly’s built-in interaction lets users inspect dense charts without creating a separate interface. The best controls narrow attention while preserving the analytical context.

👁️
See it this way

A two-year time series is useful at a glance, but an analyst may need to isolate the last quarter. A range slider or zoom can support both overview and detail in the same figure.

Core ideas

  • hover reveals point-level details
  • legend clicks can hide or show traces
  • zoom and pan support dense views
  • range sliders and selectors help focus time windows
Try this
fig = px.line(df, x="date", y="requests", color="service")

fig.update_xaxes(
    rangeslider_visible=True,
    rangeselector=dict(
        buttons=[
            dict(count=1, label="1m", step="month", stepmode="backward"),
            dict(step="all", label="All")
        ]
    )
)

fig.show()
✅

Every control should answer a plausible user question. Remove controls that create motion without insight.

Practice the decision, not just the syntax

Practice 19
What can a range slider help a user do?
Practice 20
What happens when you click a legend item in many Plotly charts?
Practice 21
What should interactive controls preserve?
MODULE 08
📤

Export and Delivery: From Notebook to Browser

The final skill is delivery. Plotly figures can be shown in notebooks, saved as interactive HTML, exported as static images with the appropriate engine, or used as building blocks for richer web applications.

👁️
See it this way

A chart for an analyst may stay interactive in HTML, while the same insight may need a static version for a slide deck. Delivery format should follow the audience and environment.

Core ideas

  • fig.write_html() saves an interactive browser file
  • fig.show() is useful during exploration
  • static export is useful for reports and slides
  • validate privacy, labels, controls and mobile readability before publishing
Try this
# Interactive browser file
fig.write_html("service_dashboard.html")

# Static export requires a compatible image export engine
# fig.write_image("service_dashboard.png")

# Re-open the HTML in a browser to validate the final experience.
✅

Share the most interactive format the audience can reliably use, but always keep a reproducible source workflow behind it.

Practice the decision, not just the syntax

Practice 22
Which method can create a standalone interactive HTML file?
Practice 23
When do static image exports become useful?
Practice 24
What is the best final step before publishing an interactive chart?
5-Question Knowledge Check

Can you explain the interactive decision before you write the code?

Open each item only after answering it in your own words.

1. What is the difference between Plotly Express and Graph Objects?

Plotly Express is high-level; Graph Objects provides lower-level control.

2. Why is hover useful?

Hover reveals detail on demand.

3. When should you use facets instead of animation?

Facets support simultaneous comparison; animation emphasizes progression.

4. When is Graph Objects worth the extra code?

Use it when the analytical composition needs deeper control.

5. What should you validate before publishing interactive charts?

Validate both the analysis and the delivery experience.

Decision Guide

Matplotlib, Seaborn or Plotly?

NeedMatplotlibSeabornPlotly
Precise low-level static controlStrongUses Matplotlib underneathStrong through Graph Objects, but web-first
Fast statistical visualization from tidy dataPossibleStrongStrong for many analytical charts
Interactive hover, zoom and browser sharingLimited by defaultLimited by defaultStrong
Interactive dashboard foundationPossible with other frameworksPossible with other frameworksNatural fit

Choose based on analysis, control and delivery needs.

Official Sources & Further Learning

Grounded in the official Plotly Python documentation

The technical concepts in this training follow Plotly’s official Python documentation.

Market Skills

What you should be able to say after this training

“I can build, refine and share interactive Plotly visualizations for analytical decision-making.”

Certificate of Participation

Complete at least 12 of the 24 practice cases (50%) and enter your name.

0 / 24 • 0%