MITB Banner

Create interactive presentations within the Python notebook with ipyVizzu

The "ipyvizzu" is an animated graphing tool for notebooks
Share
Listen to this story

Storytelling is one of the most important skills of an Analyst because the analysis has to be communicated to the stakeholders. The best way to communicate the analysis obtained from the data is by telling the story of the data. Using animations as a result of communication methods can assist the audience in rapidly grasping the point and absorbing the message delivered by the teller. This article will introduce a python framework called ipyVizzu which will help to create animated analysis within the notebook itself for presentation. Following are the topics to be covered.

Table of contents

  1. Introduction to the ipyVizzu
  2. Creating presentations with ipyVizzu

Introduction to the ipyVizzu

The “ipyvizzu” is an animated graphing tool for notebooks like Jupyter, Google Colab, Databricks, Kaggle, and Deepnote, among others. It enables data scientists and analysts to use Python animation for data storytelling. It is based on Vizzu, an open-source Javascript/C++ charting toolkit.

There is a new “ipyvizzu” extension,” ipyvizzu-story”, that allows animated charts to be shown directly from notebooks. Because the syntax of ipyvizzu-story differs from that of “ipyvizzu”, we recommend starting with the” ipyvizzu-story” repo if you want to use animated charts to show your findings live or as an HTML file. It makes use of a generic DataViz engine to produce several types of charts and easily transition between them. It is intended for creating animated data tales since it allows viewers to quickly follow multiple viewpoints of the data.

Main characteristics:

  • Designed with animation in mind.
  • Defaults based on data visualisation best practices.
  • Works with Pandas dataframes, as well as JSON and inline data input.
  • The auto-scrolling function keeps the real chart in place while running many cells.

Are you looking for a complete repository of Python libraries used in data science, check out here.

Creating stories with ipyVizzu

The article will use data related to sales, it is a time series data for multiple products and sub-products. To use the ipyVizzu needed to be installed, so let’s start with installing dependency.

!pip install ipyvizzu-story

Importing dependencies required for this article

import numpy as np
import pandas as pd
from ipyvizzu import Data, Config, Style
from ipyvizzustory import Story, Slide, Step

Since the ipyvizzu module is completely compatible with Pandas dataframes, creating graphs straight from data is a breeze. To include a dataframe in an ipyvizzu chart, first, create a Data() object and then add the dataframe to it.

data = Data()
df=pd.read_csv(file_loc)
data.add_data_frame(data_utils)

We are all set to create stories with ipyVizzu story, for creating stories it must be in the form of slides. It’s similar to a video which is a set of different frames. 

stories = Story(data=data,style=chart_designs)

The plots could be designed according to the need, one change the labels, colours, font size of the texts, orientation of the labels, etc. To customize the plots use the below code.

chart_designs = Style(
    {
        "plot": {
            "paddingLeft": "0em",
            "yAxis": {
                "label": {
                    "fontSize": "1em",
                    "paddingRight": "1.2em",
                },
                "title": {"color": "#ffffff00"},
            },
            "xAxis": {
                "label": {
                    "angle": "2.5",
                    "fontSize": "1.1em",
                    "paddingRight": "0em",
                    "paddingTop": "1em",
                },
                "title": {"fontSize": "1em", "paddingTop": "2.5em"},
            },
        }
    }
)

To create a slide the components like x-axis, y-axis, hue and title need to be configured by using “channels”. As shown in the below code.

s_1 = Slide(
    Step(
        
        Config(
            {
                "channels": {
                    "y": {
                        "set": ["Sales", "Category"],
                        "range": {"min": "0%", "max": "100%"},
                    },
                    "x": {"set": ["order_Year"]},
                    "color": "Category",
                },
                "title": "Sales for all the caetgories",
                "geometry": "area",
            }
        ),
    )
)

Then after these slides are built, you need to add them to the story built above so that it can be aggregated in one place and be in a sequence. To display the story, use the play() function.

stories.add_slide(s_1)
stories.play()
(Note: Loading of GIF might take some time. Please hold on here)

Conclusion

The ipyVizzu is really simple and easy to use once its property is properly understood and one can create animated stories. With this article, we have understood the use of the ipyVizzu package. 

References

PS: The story was written using a keyboard.
Share
Picture of Sourabh Mehta

Sourabh Mehta

Sourabh has worked as a full-time data scientist for an ISP organisation, experienced in analysing patterns and their implementation in product development. He has a keen interest in developing solutions for real-time problems with the help of data both in this universe and metaverse.
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India