Storytelling with visualization sequence helps you explain data step-by-step. It makes complex information easy to understand by showing it in parts.
0
0
Storytelling with visualization sequence in Matplotlib
Introduction
When you want to explain a trend over time clearly.
When you need to compare different groups one by one.
When you want to highlight changes in data stepwise.
When teaching data insights to people new to data.
When presenting data in meetings to keep attention.
Syntax
Matplotlib
import matplotlib.pyplot as plt # Create multiple plots in sequence plt.figure() plt.plot(x1, y1) plt.title('Step 1: First view') plt.show() plt.figure() plt.plot(x2, y2) plt.title('Step 2: Next detail') plt.show()
Use plt.show() after each plot to display them one by one.
Each plot can focus on a different part of the story.
Examples
This shows a simple line plot as the first step in a story.
Matplotlib
import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [10, 20, 25, 30] plt.plot(x, y) plt.title('Basic line plot') plt.show()
Next, a bar chart can add comparison between groups.
Matplotlib
plt.bar(['A', 'B', 'C'], [5, 7, 3]) plt.title('Bar chart to compare categories') plt.show()
Finally, a scatter plot can show detailed points.
Matplotlib
plt.scatter([1, 2, 3], [4, 5, 6]) plt.title('Scatter plot for detail') plt.show()
Sample Program
This program shows three plots one after another. Each plot tells part of the sales story: overall sales by quarter, product sales in the last quarter, and monthly sales trend.
Matplotlib
import matplotlib.pyplot as plt # Step 1: Show sales over 4 quarters quarters = ['Q1', 'Q2', 'Q3', 'Q4'] sales = [150, 200, 250, 300] plt.figure() plt.plot(quarters, sales, marker='o') plt.title('Step 1: Sales over quarters') plt.xlabel('Quarter') plt.ylabel('Sales') plt.show() # Step 2: Show sales by product in Q4 products = ['Product A', 'Product B', 'Product C'] sales_q4 = [120, 80, 100] plt.figure() plt.bar(products, sales_q4, color='orange') plt.title('Step 2: Q4 sales by product') plt.xlabel('Product') plt.ylabel('Sales') plt.show() # Step 3: Show sales trend with scatter months = [1, 2, 3, 4, 5, 6] sales_trend = [100, 150, 200, 250, 300, 350] plt.figure() plt.scatter(months, sales_trend, color='green') plt.title('Step 3: Monthly sales trend') plt.xlabel('Month') plt.ylabel('Sales') plt.show()
OutputSuccess
Important Notes
Use clear titles and labels to guide the viewer through the story.
Showing plots one by one helps keep focus on each part.
You can save each plot as an image if you want to share the story later.
Summary
Break your data story into small steps using multiple plots.
Use plt.show() to display each plot separately.
Clear titles and labels help your audience follow the story.