Jazz Up Your Data Visualization with Ipyvizzu -Part 1

Sai Prakash
5 min readAug 23, 2023
Image created using photopea

In the realm of data analysis, visualization stands as an indispensable tool that empowers us to extract insights and communicate complex information effectively. Data visualization becomes even more vital in the era of big data, where patterns and relationships might remain hidden without the proper visualization techniques. This is where Ipyvizzu, a remarkable Python library, enters the scene. In this two-part series, we embark on a journey of exploration, starting with Part 1 where we dive into the fundamentals of individual plot types within Ipyvizzu.

Introduction to ipyvizzu:

It is a dynamic charting tool compatible with Jupyter, Google Colab, Databricks, Kaggle, and Deepnote notebooks, offering data professionals the ability to employ Python for animated data-driven storytelling.

Ipyvizzu

Installation and Data Loading:

Before we plunge into the world of captivating data plots, let’s make sure we have Ipyvizzu installed. To do so, execute the following command:

!pip install ipyvizzu

We’ll be working with the Indian Food Dataset from Kaggle for our illustration purposes. This dataset encompasses a variety of culinary delights with features such as name, ingredients, diet, preparation time, cooking time, flavor profile, course, state, region, and image URL. To get started, let’s load our dataset into a Pandas DataFrame and prepare the groundwork for our visualizations.

import pandas as pd
from ipyvizzu import Chart, Data, Config, Style

# Load the dataset
df = pd.read_csv("Ifood_new.csv")
Indian Food Dataset

Bar Chart: Unveiling Preparation Time Patterns

We kick off our exploration with bar charts — an iconic visualization for comparing data across categories. In this example, we’ll visualize the preparation time of vegetarian and non-vegetarian foods.

# Initializing the chart
chart = Chart(width="640px", height="360px", display="manual")

# Loading our dataset
data = Data()
data.add_df(df)

# Animating the chart
chart.animate(data)

# Creating a bar chart for preparation time
chart.animate(
Config.bar(
{"x": "prep_time", "y": "diet", "title": "Preparation Time of Veg & Non-Veg Foods"}
)
)

chart.animate(Config({"x": "cook_time", "y": "diet", "label": "cook_time","title":"Cooking time of Veg & Non-Veg Foods"}))
chart.animate(Config({"x": ["cook_time","diet"], "label": ["cook_time","diet"], "color": "diet"}))
chart.animate(Config({"x": "cook_time", "y": ["diet"]}))
chart.animate(Style({"title": {"fontSize": 15}}))

# Displaying the chart
chart.show()
Bar Chart

Bubble Chart: Delving into Culinary Characteristics

Our journey continues with bubble charts — a powerful visualization to understand relationships between three variables. Here, we’ll use the Ipyvizzu library to depict the correlation between cooking time, preparation time, and course (main course or dessert).

# Create a bubble chart for cooking and preparation times
chart.animate(
Config(
{
"channels": {
"color": "course",
"size": "prep_time",
"label": "cook_time",
},
"geometry": "circle",
}
)
)
Bubble Chart

Line Chart: Unraveling Flavor Profile Insights

Line charts come into play to visualize trends over time or continuous data. Our next endeavor involves plotting a line chart to find out cooking time trends based on flavor profiles.

# Create a line chart for flavor profile and cooking time
chart.animate(
Config(
{
"channels": {"x": "flavor_profile", "y": "cook_time", "color": "flavor_profile"},
"geometry": "line",
}
)
)
Line Chart

Scatter Plot: Exploring Preparation and Cooking Times

Scatter plots are perfect for unveiling relationships between two numerical variables. In this example, we’ll utilize a scatter plot to examine the relationship between preparation and cooking times, while color-coding the states.

# Create a scatter plot for preparation and cooking times
chart.animate(
Config(
{
"channels": {
"y": "cook_time",
"x": "prep_time",
"color": "state",
"label": "state",
},
"geometry": "circle",
}
)
)
Scatter Plot

Dot Plot: Visualizing Regional and Flavor Variations

Dot plots provide a powerful means to visualize distribution and relationships. Our next endeavor involves a dot plot to showcase the relationship between regional variations and flavor profiles.

# Create a dot plot for regional variations and flavor profiles
chart.animate(
Config(
{
"channels": {
"x": "flavor_profile",
"y": "cook_time",
"color": "region",
},
"geometry": "circle",
}
)
)
Dot Plot

Radial Chart: Visualizing Flavor Profiles Radially

Radial charts are unique tools that represent data in a circular manner. Let’s employ a radial chart to visualize the relationship between cooking time and flavor profiles.

# Create a radial chart for flavor profile and cooking time
chart.animate(
Config(
{
"channels": {
"x": "cook_time",
"y": {"set": "flavor_profile", "range": {"min": "-100%"}},
"label": "cook_time",
},
"coordSystem": "polar",
}
)
)
Radial Chart

Stacked Stream Chart: Unveiling Course and Preparation Patterns

Our journey culminates with the stacked stream chart, a dynamic visualization for revealing trends in data over time. Here, we explore the course and preparation time patterns using this innovative chart type.

# Create a stacked stream chart for course and preparation time
chart.animate(
Config(
{
"channels": {
"x": "course",
"y": ["prep_time", "flavor_profile"],
"color": "flavor_profile",
},
"geometry": "area",
"align": "center",
}
),
Style(
{"plot": {"yAxis": {"label": {"numberScale": "K, M, B, T"}}}}
),
)
Stacked Stream Chart

Conclusion

In Part 1 of our Ipyvizzu exploration, we’ve immersed ourselves in a series of powerful and insightful data visualizations. We’ve witnessed how bar charts, bubble charts, line charts, scatter plots, dot plots, radial charts, and stacked stream charts can provide unique perspectives on our data. These visualizations help us comprehend trends, relationships, and patterns that might otherwise remain obscured. Stay tuned for Part 2 of our series, where we delve into Ipyvizzu-story — an extension of Ipyvizzu that allows us to create compelling narratives enriched with interactive visualizations and share them as anHTMLfile. Your journey to becoming a data visualization maestro has only just begun!

Thanks for the read. So what do you guys think? I’ll be interested to know your thoughts on it. I hope I’ve given you a brief idea about creating an creating interactive and high-quality visualizations using ipyvizzu library. Give it a 💚, if you like this post for extra motivation. I’m always open to your suggestions and queries.

--

--

Sai Prakash

Data Analyst@Sargaa | ML Practitioner | Game Developer