Five Non‑Traditional Plotly Visualization Techniques for Data Storytelling
This article introduces five unconventional Plotly visualizations—including animated bar charts, sunburst charts, parallel categories, parallel coordinates, and gauge indicators—demonstrating how to create dynamic, interactive graphics in Python to make data stories more engaging and informative.
Data helps us describe the world, but plain text and numbers often fail to capture an audience; a well‑designed visualization can convey insights more effectively. This article presents five non‑traditional Plotly visualization methods that go beyond basic histograms and box plots, offering dynamic and interactive options for data storytelling.
Why use Plotly? Plotly integrates seamlessly with Jupyter Notebook, can be embedded in websites, and fully supports Dash for building dashboards and analytical applications.
Installation
<code>pip install plotly</code>Animation – With a single line of code you can animate data over time. Example code creates an animated bar chart of natural disaster deaths:
<code>import plotly.express as px
from vega_datasets import data
df = data.disasters()
df = df[df.Year > 1990]
fig = px.bar(df,
y="Entity",
x="Deaths",
animation_frame="Year",
orientation='h',
range_x=[0, df.Deaths.max()],
color="Entity")
fig.update_layout(width=1000, height=800,
xaxis_showgrid=False,
yaxis_showgrid=False,
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)',
title_text='Evolution of Natural Disasters',
showlegend=False)
fig.update_xaxes(title_text='Number of Deaths')
fig.update_yaxes(title_text='')
fig.show()</code>Similarly, a scatter plot animation can be built with Plotly Express using the Gapminder dataset.
<code>import plotly.express as px
df = px.data.gapminder()
fig = px.scatter(df,
x="gdpPercap",
y="lifeExp",
animation_frame="year",
size="pop",
color="continent",
hover_name="country",
log_x=True,
size_max=55,
range_x=[100, 100000],
range_y=[25, 90])
fig.update_layout(width=1000, height=800,
xaxis_showgrid=False,
yaxis_showgrid=False,
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)')
fig.show()</code>Sunburst Chart – Ideal for visualizing hierarchical group‑by results. Example code creates a sunburst of tipping habits by gender and time of day:
<code>import plotly.graph_objects as go
import plotly.express as px
import numpy as np
import pandas as pd
df = px.data.tips()
fig = go.Figure(go.Sunburst(
labels=["Female", "Male", "Dinner", "Lunch", "Dinner ", "Lunch "],
parents=["", "", "Female", "Female", "Male", "Male"],
values=np.append(
df.groupby('sex').tip.mean().values,
df.groupby(['sex', 'time']).tip.mean().values),
marker=dict(colors=px.colors.sequential.Emrld)))
fig.update_layout(margin=dict(t=0,l=0,r=0,b=0),
title_text='Tipping Habbits Per Gender, Time and Day')
fig.show()</code>The hierarchy can be extended with additional layers (e.g., day of week) by adding more labels, parents, and values.
Parallel Categories – Visualize relationships among categorical variables. Example code creates a parallel‑categories diagram of movie genres, MPAA ratings, and creative types:
<code>import plotly.express as px
from vega_datasets import data
import pandas as pd
df = data.movies()
df = df.dropna()
df['Genre_id'] = df.Major_Genre.factorize()[0]
fig = px.parallel_categories(df,
dimensions=['MPAA_Rating', 'Creative_Type', 'Major_Genre'],
color="Genre_id",
color_continuous_scale=px.colors.sequential.Emrld)
fig.show()</code>Parallel Coordinates – Continuous version of the above, useful for spotting outliers, clusters, trends, and redundant variables. Example code visualizes several movie attributes:
<code>import plotly.express as px
from vega_datasets import data
import pandas as pd
df = data.movies()
df = df.dropna()
df['Genre_id'] = df.Major_Genre.factorize()[0]
fig = px.parallel_coordinates(df,
dimensions=['IMDB_Rating','IMDB_Votes','Production_Budget','Running_Time_min','US_Gross','Worldwide_Gross','US_DVD_Sales'],
color='IMDB_Rating',
color_continuous_scale=px.colors.sequential.Emrld)
fig.show()</code>Gauge Indicator – Useful for KPI dashboards. Example code creates a gauge showing a success metric with a reference value:
<code>import plotly.graph_objects as go
fig = go.Figure(go.Indicator(
domain={'x':[0,1],'y':[0,1]},
value=4.3,
mode="gauge+number+delta",
title={'text':'Success Metric'},
delta={'reference':3.9},
gauge={'bar':{'color':'lightgreen'},
'axis':{'range':[None,5]},
'steps':[{'range':[0,2.5],'color':'lightgray'},
{'range':[2.5,4],'color':'gray'}]}))
fig.show()</code>These techniques demonstrate how Plotly can turn ordinary data into compelling, interactive visual stories, enhancing communication and insight delivery.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.