Stop 03 · Data Manipulation & VisualizationTopics · 9/10

Plotly (Interactive Charts)

Part of the AI Engineer Roadmap

In short

A static chart can't answer 'which point is that?' or 'what if I zoom into March?'. Plotly charts let you hover, zoom and toggle groups, which makes them great for exploring and for dashboards.

An interactive charting library (hover, zoom, filter) — useful for dashboards and exploratory notebooks where static images aren't enough.

The purple blob pinches to zoom into a colourful bar chart on a tablet.

Think of it like this

A printed photo vs a phone gallery

A printed photo shows what it shows. On your phone, you pinch to zoom on a face, swipe, and tap for details. Matplotlib gives you the printed photo. Plotly gives you the phone version, where the viewer explores the chart themselves.

Watch it happen

Exploring a Plotly scatter

You
Plotly chart

hover a dot

1/5You move the mouse over one point.

The big ideas

What you need to know

plotly.express is the fast path

px.scatter, px.line, px.bar and px.histogram take a DataFrame and column names, much like Seaborn.

Interaction is free

Hover, zoom, pan and legend toggles work without any extra code.

Charts are HTML

fig.write_html('chart.html') saves a file anyone can open in a browser, no Python needed.

Built for dashboards

Plotly figures drop straight into Dash and Streamlit apps.

See it in code

Walk through the code

python
1import plotly.express as px2 3df = px.data.gapminder().query("year == 2007")   # built-in sample data4 5fig = px.scatter(6    df, x="gdpPercap", y="lifeExp",7    size="pop", color="continent",8    hover_name="country", log_x=True,9    title="Richer countries tend to live longer (2007)",10    labels={"gdpPercap": "GDP per person", "lifeExp": "Life expectancy"},11)12fig.show()13fig.write_html("life_vs_gdp.html")

1/4Plotly ships small sample datasets. query keeps only 2007.

Hover any bubble to see the country. log_x=True spreads out the poorer countries that would otherwise bunch up on the left.

Save yourself the pain

Common mistakes

Oops

Using interactive charts in a PDF report or a printed slide.

Do this instead

Interaction only helps on screens. Export a static image or use matplotlib for print.

Oops

Plotting hundreds of thousands of points and freezing the browser.

Do this instead

Sample or aggregate first, or use px.density_heatmap for very large data.

Your mission

Make a chart people can play with

~20 min

Quick check

You need to send a manager a chart they can zoom into without installing Python. What do you send?

Go deeper

  1. 1Build an interactive scatter or line chart with hover tooltips.
  2. 2Learn Plotly Express for quick charts vs. the lower-level graph_objects API.
  3. 3Embed a Plotly chart in a small dashboard or notebook report.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge