Using Scalable Visualizations in Python Using PyGal

Data Visualization helps in understanding hidden data patterns and analyzing what data is trying to say. By creating different types of charts and plots we can understand the association and collinearity between the different of the dataset with the target variable.

Python provides a large number of data visualization libraries like Seaborn, Matplotlib, etc. The problem with these libraries is that the visualization we create is not scalable which means that it is only available in PNG and JPEG format. Sometimes using these visualizations becomes challenging due to their limitations.

PyGal is an open-source Python library that is used for creating Data Visualizations that can be downloaded and used in a variety of applications. One of the main advantages of using PyGal is that the visualizations created can be downloaded in SVG format.

In this article, we will explore PyGal and create some visualizations using it.

Let’s get started…

We will start by installing PyGal using pip installation. The command given below will install PyGal using pip.

pip install pygal

In this step, we will import all the libraries that are required for creating data visualization.

import pygal
import seaborn as sns

For this article, we will be using the famous Tips dataset from seaborn.

df = sns.load_dataset('tips')

Now we will start by creating some basic visualization using PyGal. We will also create the dataset that we want to visualize.

  1. Simple Bar Chart
bar_chart = pygal.Bar()  
bar_chart.add('Tip', df['tip'])

2. Double Bar Chart

bar_chart.add('Tip', df['tip'][:10])
bar_chart.add('Total Bill', df['total_bill'][:10])

3. Line Chart

line_chart = pygal.Line()
line_chart.add('Total Bill', df['total_bill'][:15])

4. Double Line Chart

line_chart.add('Total Bill', df['total_bill'][:15])
line_chart.add('Tips', df['tip'][:15])

5. Box Plot

box_plot = pygal.Box()
box_plot.title = 'Tips Dataset'
box_plot.add('Tips', df['tip'])

6. Funnel Chart

funnel_chart = pygal.Funnel()
funnel_chart.title = 'Total Bill'
funnel_chart.add('Total Bill', df['total_bill'][:15])

Continue reading:—-7f60cf5620c9—4