How can Pygal be used to generate Funnel plots in Python?

Visualizing data is an important step since it helps understand what is going on in the data without actually looking at the complicated working underneath it and performing complicated computations.

Pygal is an open source Python package that helps in the creation of interactive plots, and SVG (Scalar Vector Graphics) images of graphs. SVG refers to dynamically generating animated graphs with the given data. These SVG images of graphs can be used and customized depending on our requirements. The SVG images are highly scalable, hence they can be downloaded in high quality format. These downloaded images can also be embedded to various projects, websites and so on.

These interactive and customized graphs can be created with ease in Pygal. Pygal helps create bar chart, histogram, line plot, and much more.

Funnel charts help visualize progressive reduction or expansion in the dataset, when it passes through different phases. It can be used to represent sales data, stock data, and so on.

Pygal package can be installed using the below command on Windows −

pip install Pygal

Let us understand how Funnel charts be created using Pygal −


import pygal
from import Style
custom_style = Style(colors=('#E80080', '#404040', '#9BC850', '#E81190'))

funnel_chart = pygal.Funnel(height=400,width = 300,style=custom_style)
funnel_chart.title = "Funnel plot"
funnel_chart.add("label 1", [0.4])
funnel_chart.add("label 2", [1.2])
funnel_chart.add("label 3", [1.5])
funnel_chart.add("label 3", [1.8])




  • The required packages are imported into the environment.

  • The pygal.Funnel function is called with a few parameters.

  • This is assigned to a variable that is used to add characteristics.

  • The colors for the funnel plots are defined.

  • The height and width of the graph is also defined.

  • The title and values for the funnel plots are defined.

  • The ‘render_in_browser’ function is called to plot the generated funnel plot in the browser.

Updated on: 19-Jan-2021


Kickstart Your Career

Get certified by completing the course

Get Started