TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

Level Up Your Data Storytelling with Animated Bar Charts in Plotly

Transforming static plots into captivating narratives

Brian Mattis
TDS Archive
Published in
6 min readDec 2, 2023
Photo by Teemu Paananen on Unsplash

Plotly supports an excellent foundation for animated plots. I highly recommend their basic tutorial here. However, plotly animations are primarily set up to add another dimension to the visualization — usually time. This is fantastic for adding more meaning to a plot.

Animation, however, doesn’t have to be used to add complexity to a plot. The ability to emphasize with animation is powerful. When we have the pivotal graph for our audience, we want to pull in their attention without explicitly shouting “This is the plot you should really pay attention to!” Our eyes are naturally drawn to things moving, and animated plots can have a way of building up anticipation. Your audience engages and mentally tries to anticipate next bar or line in real time. Imagine if key business decisions hinge on this plot — your audience waits with baited breath while the results unfold before their eyes!

To put it in perspective — imagine you’re 20 minutes into a colleague’s presentation — which graph grabs your attention? This simple (pandas-generated) graph:

Basic bar plot — Image by Author

Or this animated graph of the same data:

Custom Plotly animated bar plot — Image by Author

Building in Plotly

To pull this off in Plotly, we actually have to reshuffle our data a bit. Again, Plotly animations are set up to step with some sequence (usually time). So, we’re going to stretch our data to effectively make a frame for each data point. Here we go:

First, let’s import the plotly package (install with pip if you haven’t already), and create a dummy data set to work with:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Brian Mattis
Brian Mattis

Written by Brian Mattis

Semiconductor Engineer by day, Data Scientist by night.

No responses yet

Write a response