Skip to content
Related Articles

Related Articles

Gauge Chart in pygal
  • Last Updated : 03 Jul, 2020

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.

Gauge Charts

Gauge charts are also known as dial charts or speedometer charts. This type of chart is often used in executive dashboard reports to show key business indicators. Gauge charts are much useful for comparing the values between a small number of variables either by using multiple needles on the same gauge or by using multiple gauges. It shows the maximum, the minimum, and the present value of data being analyzed. It can be created using the Gauge() method.

Syntax:

gauge_chart = pygal.Gauge()

Example 1:




# importing pygal
import pygal
import numpy
  
  
# creating the chart object
gauge = pygal.Gauge()
  
# naming the title
gauge.title = 'Gauge Chart'        
  
# Random data
gauge.add('A', numpy.random.rand(10))
gauge.add('B', numpy.random.rand(10))
gauge.add('C', numpy.random.rand(10))
gauge.add('D', numpy.random.rand(10))
  
gauge

Output:



Example 2:




# importing pygal
import pygal
  
# creating the chart object
gauge = pygal.Gauge()
  
# naming the title
gauge.title = 'Gauge Chart'     
  
gauge.range = [0, 5000]
  
# Random data
gauge.add('A', 1000)
gauge.add('B', 2000)
gauge.add('C', 3500)
  
gauge

Output:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :