How to use Pygal in Python?
To use the Pygal library we have to first import it into our Python Program using the import command and then we have to create the instance of plot or chart. In the below example, we have created the instance of a bar plot using pygal.Bar() method. After that, we created the Bar Chart by passing adding some random data and saving the bar chart as a ‘BarPlot.svg’ file using the render_to_file() method.
Python3
# import Pygal module import pygal # Creating an instance of Bar Plot Bar_plot = pygal.Bar() # Creating a bar Plot using random data Bar_plot( 1 , 3 , 3 , 7 )( 1 , 6 , 6 , 4 ).render_to_file( 'BarPlot.svg' ) |
Output: We can see in the below output that when we hover over the bar it shows data of that bar.
Pygal Introduction
Python has become one of the most popular programming languages for data science because of its vast collection of libraries. In data science, data visualization plays a crucial role that helps us to make it easier to identify trends, patterns, and outliers in large data sets. Pygal is best suited for Data visualizations. It is used to draw charts and plots such as bar plots, line charts, and box plots.
Contact Us