Skip to content Skip to footer

Level Up Your Data Storytelling with Animated Bar Charts in Plotly | by Brian Mattis | Dec, 2023

[ad_1]

Transforming static plots into captivating narratives

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

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:

[ad_2]

Source link