Pygal is a Python module that is mainly used to build SVG (Scalar Vector Graphics) graphs and charts. SVG is a vector-based graphics in the XML format that can be edited in any editor. Pygal can create graphs with minimal lines of code that can be easy to understand and write.
Histogram
The histogram is a graphical display of data using bars of different heights, it is similar to bar chart but the histogram presents the number of groups into ranges and presents them in segment columns. Histogram chart is only used for plotting the frequency of score occurrences in a continuous data set that has been divided into classes, called bins. Histogram are those type of special bars which take 3 values for a bar:
- The ordinate height
- The abscissa start
- The abscissa end
Syntax:
hist = pygal.Histogram()
Example 1:
import pygal
import numpy
histogram = pygal.Histogram()
histogram.title = 'Stacked Bar Chart'
for i in range ( 5 , 20 , 10 ):
data = list ( zip (numpy.random.rand(i),
numpy.random.rand( 3 ),
numpy.random.rand(i)))
histogram.add( str (i), data)
histogram
|
Output:

Example 2:
import pygal
import numpy
histogram = pygal.Histogram()
histogram.title = 'Histogram'
histogram.add( 'A' , [( 2 , 2 , 3.9 ), ( 3 , 2 , 8 ), ( 3 , 4 , 2.4 )])
histogram.add( 'B' , [( 1.5 , 0 , 2 ), ( 6 , 2 , 3 ), ( 7 , 3 , 2 )])
histogram
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!