Interactive Charts with Plotly

Building interactive, shareable charts and simple data apps in Python with Plotly Express and friends.

Intermediate · about 4 hours · difficulty 2/5

Learn first: Plotting in Python with Matplotlib and Seaborn

Interactive charts let readers hover for exact values, zoom into time ranges and toggle series. They are great for exploration and for sharing results with people who like to dig.

Plotly Express

  • One-line charts from DataFrames: px.line(df, x="date", y="revenue", color="region").
  • Hover data, facets (facet_col), animations over time (animation_frame), and maps.
  • Export to standalone HTML with fig.write_html("chart.html") to share without any server.
  • Works inside Jupyter, Colab and VS Code.

Customising

Use fig.update_layout and fig.update_traces for titles, templates, axis formats and hover text. Keep the same design discipline as static charts: interactivity does not excuse clutter.

Beyond single charts

  • Dash (from Plotly) and Streamlit turn Python scripts into small web apps with filters and widgets. Handy for internal tools or a portfolio demo.
  • Altair is a declarative alternative based on the grammar of graphics.

When not to use interactivity

Slides, printed reports and executive emails need a static chart with the insight already highlighted. Do not make readers hunt for the point.

Pitfall: sharing huge HTML files with hundreds of thousands of points; aggregate first. Move on when you can build an interactive chart with meaningful hover text and share it as a single HTML file.

Key concepts

  • Plotly Express basics
  • Hover data and facets
  • Exporting to HTML
  • Layout and trace customisation
  • Streamlit apps
  • Dash apps
  • Altair

Mini project

Build an animated Plotly scatter of Gapminder data (GDP per capita vs life expectancy by year, sized by population) and publish it as an HTML file in your portfolio repo.

Check yourself

When would an interactive chart be the wrong choice for communicating a result?

Free resources