Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
About Article
Analyze Data
Archive
Best Practices
Better Outputs
Blog
Code Optimization
Code Quality
Command Line
Daily tips
Dashboard
Data Analysis & Manipulation
Data Engineer
Data Visualization
DataFrame
Delta Lake
DevOps
DuckDB
Environment Management
Feature Engineer
Git
Jupyter Notebook
LLM
LLM
Machine Learning
Machine Learning
Machine Learning & AI
Manage Data
MLOps
Natural Language Processing
NumPy
Pandas
Polars
PySpark
Python Tips
Python Utilities
Python Utilities
Scrape Data
SQL
Testing
Time Series
Tools
Visualization
Visualization & Reporting
Workflow & Automation
Workflow Automation

ipyvizzy-story: Creating Animated Visualizations in Python

Table of Contents

ipyvizzy-story: Creating Animated Visualizations in Python

Creating interactive animated data presentations in notebooks often requires complex code with multiple visualization libraries, resulting in non-linear storytelling and difficult-to-follow transitions between different chart states.

import seaborn as sns  

df = sns.load_dataset("penguins")
df = df[['species', 'sex']].dropna()
df = df.astype("object")
df["count"] = 1
df.head(10)
speciessexcount
0AdelieMale1
1AdelieFemale1
2AdelieFemale1
4AdelieFemale1
5AdelieMale1
6AdelieFemale1
7AdelieMale1
12AdelieFemale1
13AdelieMale1
14AdelieMale1
# Traditional approach: Multiple separate visualizations
import seaborn as sns
import matplotlib.pyplot as plt

# First view - grouped bar chart
plt.figure(1)
sns.barplot(data=df, x='sex', y='count')
plt.show()

# Second view - separate plot for stacked bars
plt.figure(2)
sns.barplot(data=df, x='count', y='species', hue='sex')
plt.show()

# No smooth transitions between views
# Manual navigation between plots

ipyvizzu-story enables creation of fluid data stories with smooth transitions between insights:

from ipyvizzu import Data, Config
from ipyvizzustory import Story, Slide, Step

data = Data()
data.add_df(df)
story = Story(data=data)

slide1 = Slide(
    Step(
        Config({"x": ["count", "sex"], "label": ["count", "sex"], "color": "sex"})
    )
)
story.add_slide(slide1)

slide2 = Slide(
    Step(
        Config({"x": "count", "y": ["species", "sex"]})
    )
)
story.add_slide(slide2)

story.play()

The example shows how ipyvizzu-story simplifies creating interactive presentations by handling transitions automatically. You define different views as slides, and the library creates smooth animations between them, including keyboard navigation controls.

Link to ipyvizzu-store.

Leave a Comment

Your email address will not be published. Required fields are marked *

0
    0
    Your Cart
    Your cart is empty
    Scroll to Top

    Work with Khuyen Tran

    Work with Khuyen Tran