Unlock the full potential of AI with Building LLMs for Production—our 470+ page guide to mastering LLMs with practical projects and expert insights!

Publication

Hand Made Visualizations in Python using Cutecharts
Data Visualization   Latest   Machine Learning

Hand Made Visualizations in Python using Cutecharts

Last Updated on May 9, 2024 by Editorial Team

Author(s): Kashish Rastogi

Originally published on Towards AI.

Want to add a sprinkle of sweetness to your infographics?

Okay, this blog will not be like old blogs where I will be listing out how to make charts using Python libraries.

As a data enthusiast and practitioner, I was no stranger to the world of charts and graphs. Yet, despite my best efforts, my visualizations lacked that certain punch and sweetness. I will never forget a time when I would surf endlessly through the internet just to find a way to make the charts more interesting.

Let’s just say i got a box full of sweetness in the form of Cutecharts!

Enter Cutecharts! into the menu of the Python library. It’s like the cupcake of data visualization — adding the personal touch that makes charts less intimidating and more inviting.

Unlike the typical Matplotlib and Seaborn libraries, we have somehting fun and enjoyfull charting libary.

Cutecharts brings handmade charm to the table, with adorable charts that are as delightful as they are informative. Plus, it’s got a hovering effect (just like Plotly), giving you control over your data.

From sweet Bar and Pie charts to spunky Radar, Scatter, and Line charts, Cutecharts has got your back. It’s like having a chart-making BFF who’s always there to make your data look fabulous!

Before we start to draw cute charts, we need to install the cutechart library using pip.

$ pip install cutecharts

Let us use the traditional dataset (Netflix) for exploring cutechart library.

# Importing library 
import cutecharts.charts as ctc

# Importing data
import pandas as pd

Reading the Netflix dataset

df_netf = pd.read_csv('../input/netflix-shows/netflix_titles.csv')
df_netf[:2]
Netflix Dataset

let’s whip up some data magic with Cutecharts!

Charts

First, we will make the basic chart — Pie.

Don’t picture a desert Pie, we will make a Pie Chart that is as delightful as grandma’s apple pie! With Cutecharts, you can slice and dice your data into mouthwatering segments or even eat the whole pie.

To make a pie chart we will collect the latest 5 years of movie count. First, we will collect the data of latest release year count using the value_counts() function.

df_year = df_netf['release_year'].value_counts().reset_index().sort_values(by='index', ascending=False)[:5].rename(columns={'index':'release_year','release_year':'Count'})

Pie chart

pie_chart = ctc.Pie('Last 5 years movies count', width='600px', height='300px')

# set the chart option
pie_chart.set_options(labels=list(df_year['release_year']), inner_radius=0)

# label to be shown on graph while hovering the chart (eg: count number 1147)
pie_chart.add_series(list(df_year['Count']))

# display the chart
pie_chart.render_notebook()
Pie chart

Parameters of the chart

  • width : Specify the width of the chart
  • height : Specify the height of the chart
  • labels : Specify the labels of the chart, which we want to put in the chart
  • inner_radius : Specify the inner radius of the chart, 0 means there will be no space in the middle of the chart

To make a piechart, we will first use the ctc.Pie() and use other parameters as per the need of the chart. Now, setting the chart options using the variable_name.set_options() such as labels for the x-axis and y-axis.

Donut chart

Who says data visualization can’t be sweet? Meet the Donut Chart, we will make using the Python Library.

It is a delightful twist on the classic Pie Chart.

With Cutecharts, you can serve up your data in a tasty ring of information. It’s like having your data and eating it too! So let’s go ahead, let’s indulge in some data donuts and satisfy the night and day craving for data insights.

# Donut chart
donut_chart = ctc.Pie('Last 5 years movies count', width='600px', height='300px')

# set the chart options
donut_chart.set_options(labels=list(df_year['release_year']), inner_radius=0.7)

# label to be shown on graph
donut_chart.add_series(list(df_year['Count']))

# display the charts
donut_chart.render_notebook()
Donut Chart

Parameter of the chart

  • width : Specify the width of the chart
  • height : Specify the height of the chart
  • labels : Specify the labels of the chart, which we want to put in the chart
  • inner_radius : Specify the inner radius of the chart, 0.7 means there will be space in the 70% area

To make a donut chart we will first use the ctc.Pie() and use other parameters as per the need of the chart. Now, setting the chart options using the variable_name.set_options() such as labels for the x-axis and y-axis.

Bar chart

I can feel the heat of raising the heat of sweetness with the Cutecharts’ Bar Chart!

Whether you’re plotting sales figures or ranking your favorite ice cream flavors, this chart is your go-to chart. It serves up visual refreshments with style usign the Cutecharts’ Bar Chart. With colorful bars that pop like confetti, data has never looked so festive.

Cheers to making charts as fun as happy hour!

rating = pd.DataFrame(df_netf['rating'].value_counts()).reset_index()[:7].rename(columns={'index':'rating','rating':'count'})


# bar chart
bar = ctc.Bar("Distribution of Rating")

# set the chart options
bar.set_options(labels=list(rating.rating),
x_label='Rating',
y_label='Count')

# label to be shown on graph
bar.add_series('Count',list(rating['count']))

# display the chart
bar.render_notebook()
Bar chart

Parameters of the chart

  • width : Specify the width of the chart
  • height : Specify the height of the chart
  • labels : Setting the value for the labels in the chart
  • x_label : Setting the value for the x labels in the chart
  • y_label : Setting the value for the y labels in the chart

To make a bar chart we will first use the ctc.Bar() and use other parameters as per the need of the chart. Now, setting the chart options using the variable_name.set_options() such as labels for the x-axis and y-axis.

Line chart

Let’s take a bareke from the sweetness and use something which is more informative to use in the chart.

Get ready to connect the dots and chart your course to success with Cutecharts’ Line Chart! Like a trusty GPS for your data journey, this chart helps you navigate trends and patterns with ease. Whether you’re tracking stock prices or plotting your rollercoaster emotions throughout the day, this Line Chart keeps you on the straight and narrow path to data enlightenment.

To make a line chart we will collect the first 15 years of movie’s impact.

data = df_netf.groupby('release_year').count()['show_id'].reset_index().head(15)


chart = ctc.Line("Impact of First 15 Movie over the years of 19's", width='700px', height='500px')

# set the chart options
chart.set_options(labels=list(data['release_year']),
x_label='Years',
y_label='Count',
)

# label to be shown on graph
chart.add_series('Years',list(data['show_id']))

# display the chart
chart.render_notebook()
Line chart

Parameters of the chart

  • width : Specify the width of the chart
  • height : Specify the height of the chart
  • labels : Setting the value for the labels in the chart
  • x_label : Setting the value for the x labels in the chart
  • y_label : Setting the value for the y labels in the chart

To make a line chart we will first use the ctc.Line() and use other parameters as per the need of the chart. Now, setting the chart options using the variable_name.set_options() such as labels for the x-axis and y-axis. To set the values in the x-axis use variable_name.add_series() where add the values in the form of a list.

Conclusion

In the world of data visualization, where charts and graphs show all the information, adding a touch of sweetness can make all the difference. With Cutecharts, we’ve unlocked a treasure trove of delightful charts that not only inform but also enchant.

Gone are the days of boring bar charts and uninspired line graphs. Thanks to Cutecharts, we can now infuse our data with personality and flair, creating visualizations that are as charming as they are informative.

So, the next time you find yourself lost in a sea of bland charts, remember this: Cutecharts is your secret weapon for turning data into something truly delightful. Cheers to making charts as fun as a happy hour!

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓